in reply to Get Position of Element in an array

Nothing seems to beat the obvious for efficiency in my mind:-
my @input=('a','b','c','d'); my $char='b'; # -------------- my $pos = -1; ELM: for ( my $i = 0; $i <= $#input; $i++ ) { if ( $char eq $input[$i] ) { $pos = $i; last ELM; } }
with $pos now having -1 for no match or 0+ for where the match was made in the array.

One world, one people