in reply to better array plucking?
This is what grep was designed to do:
@a = grep { not is_unwanted($_) } @a;
Update: and if you really need to modify the array in place, using splice, then you can iterate on the indices in reverse:
my @a = qw(bob bob alice bob john); for (reverse 0 .. $#a) { splice @a, $_, 1 if $a[$_] eq "bob"; }
|
|---|