in reply to Is it safe to append to the array you are iterating over
If you don't mind consuming the array:
or a manual index value to preserve the array contents:while (@array) { $item = shift @array; ... push @array, @newstuff; }
for (my $i=0; $i< $#array; $i++) { ... push @array, $thing if desired(); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is it safe to append to the array you are iterating over
by DrWhy (Chaplain) on Mar 14, 2013 at 19:03 UTC | |
by ikegami (Patriarch) on Mar 16, 2013 at 19:53 UTC |
In Section
Seekers of Perl Wisdom