my @goners; for (0 .. $#ARGV) { unshift @goners, $_ if $ARGV[$_] eq 'hello'; } splice @ARGV, $_, 1 for @goners;