I encountered the same problem on a project of mine. The solution I came up with to avoid manipulating the loop variable in a for-loop was processing the whole array backwards. This might or might not help you:
#!perl
use strict;
use warnings;
my @foo = (0..9);
for (reverse(0..$#foo)) {
splice @foo, $_, 1
if $_ % 2;
}
print join ' ', @foo;
Hope this helped.
CombatSquirrel.
Update: Argghh,
Zaxo was faster than I...
Entropy is the tendency of everything going to hell.