for my $idx (reverse 0 .. $#array) { my $item = $array[$idx]; if (some_test($item)) { splice(@array, $idx, 1); # remove the element } }