my $pos; for (0..$#array) { $pos=$_ and last if $array[$_] eq $wanted; } @array[$pos,-1]=@array[-1,$pos]; #### my $pos; for (0..$#array) { $pos=$_ and last if $array[$_] eq $wanted; } @array=@array[0..$pos-1, $pos+1..$#array, $pos]; #### @array=((grep $_ ne $wanted, @array), $wanted); #### @array = do { my $i; (grep $i || $_ ne $wanted || $i++, @array), $i ? $wanted : (); }; # or, as a sub: sub move { my ($wanted, $i)=shift; (grep $i || $_ ne $wanted || $i++, @_), $i ? $wanted : (); }