Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Different result for 'foreach' vs 'while shift' arrayref

by sundialsvc4 (Abbot)
on Apr 18, 2014 at 13:02 UTC ( #1082759=note: print w/ replies, xml ) Need Help??

in reply to Different result for 'foreach' vs 'while shift' arrayref

Incidentally, is there documentation of the behavior of foreach if the contents of the array are volatile during the loop?   And of unshift vs. push in such a frightful but-it-happens scenario?

Comment on Re: Different result for 'foreach' vs 'while shift' arrayref
Replies are listed 'Best First'.
Re^2: Different result for 'foreach' vs 'while shift' arrayref
by kcott (Canon) on Apr 19, 2014 at 06:47 UTC

    Yes. See the "Foreach Loops" section of "perlsyn - Perl syntax":

    "If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that."

    -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1082759]
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: (6)
As of 2015-10-14 04:22 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (320 votes), past polls