You can do that by taking the indexes in reverse order. Added slots in the array move the higher indexes, but leave the lower ones alone.
for ( reverse(0..$#array) ) { if ( the_condition($array[$_]) ) { splice @array, $_, 1, the_sub($array[$_]) } }
After Compline,
Zaxo
In reply to Re: Inserting into an array while stepping through it
by Zaxo
in thread Inserting into an array while stepping through it
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |