Help for this page

Select Code to Download


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