Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)

by YuckFoo (Abbot)
on Oct 10, 2005 at 02:34 UTC ( #498690=note: print w/ replies, xml ) Need Help??


in reply to Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)

I would rather use a variable for each part of the range instead of trying to represent the whole range as a string to be evalled.

Yuck..Foo

#!/usr/bin/perl use strict; my $beg = 1; my $end = 5; for my $i ($beg..$end) { print "$i\n"; }


Comment on Re: Iterate string like, for(1..5) i.e. $stirng="1..5"; for($string)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://498690]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-12-26 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (167 votes), past polls