in reply to 'For' loop bails out early?
Because you're modifying the array you're iterating over which is a no-no. See perlsyn for the details, but the cliffs notes is use while if you're modifying the array in place just as you've discovered.
Update: OK, it's not really extensive details; here's the warning in its entirety:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 'For' loop bails out early?
by Anonymous Monk on May 31, 2007 at 15:39 UTC |