in reply to Re: Array Processing
in thread Array Processing
This doesn't exactly answer why, but the behavior is documented in perlsyn:
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.
As for "why", I think that's best answered with a question: "What do you think should happen if you remove elements as you iterate over them?" Since that question has no good answer, the answer to 'why' is "Because there's no good single answer to the question of what should happen."
Dave
|
|---|