http://www.perlmonks.org?node_id=1023513


in reply to Is it safe to append to the array you are iterating over

If you don't mind consuming the array:

while (@array) { $item = shift @array; ... push @array, @newstuff; }
or a manual index value to preserve the array contents:
for (my $i=0; $i< $#array; $i++) { ... push @array, $thing if desired(); }