Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Mutable foreach list?

by zigdon (Deacon)
on Jan 11, 2007 at 15:57 UTC ( #594187=note: print w/replies, xml ) Need Help??


in reply to Re: Mutable foreach list?
in thread Mutable foreach list?

Right - I'm on forbidden ground. Perlsyn says:
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
I guess what's happening is something like this (psudocode):
$it = &make_list_into_iterator(LIST); $count = $it->figure_out_element_count; while ($count-- > 0) { $_ = $it->next; CODE }
Which fits the behaviour I see.

-- zigdon

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2019-05-22 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!