Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: How foreach loops decide what to iterate through

by jethro (Monsignor)
on Feb 14, 2009 at 02:54 UTC ( [id://743756]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How foreach loops decide what to iterate through
in thread How foreach loops decide what to iterate through

You are looping over an array you are adding to, so you are never reaching the end.

This is somewhat similar to the following loop

my $i=1; my $end= 2; while ($i++<$end) { $end++; }

Note that

y @a = (1); foreach (sort @a) { push @a, 1; }

stops immediately, because here you are looping over the anonymous array that is not expanding.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://743756]
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-04-17 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found