@out = map{ $_ == $target and last } @in; #### sub x{ my $target = shift; map { return if $_ == $target; } @_; } print for x( 5, 1 ,, 9 ); 0 1 2 3 4