Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: foreach to for

by ioannis (Abbot)
on Jun 19, 2006 at 09:07 UTC ( [id://556207]=note: print w/replies, xml ) Need Help??


in reply to foreach to for

As shown bellow, the first for loop produces fixed iterations, and the second dives into infinite loop. Although expectations are not consistent, at least you get to chose which method to want.
## Fixed-length Loop my $i=6; for (0..$i) { print ; $i++; } #### Infinite Loop my @nums = 1..3; for (@nums) { push @nums, $_; print; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-19 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found