Help for this page
my ($pos) = grep $input[$_] eq $val, 0 .. $#input;
my ($first, $last) = ({}, {}); @$first{reverse @input} = reverse 0 .. $#input; ... my $val = 'b'; print "Last index : ", $last->{$val}; print "First index : ", $first->{$val};