Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 ( [id://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"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found