Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 chanting in the Monastery: (5)
As of 2015-07-04 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls