my ($pos) = grep $input[$_] eq $val, 0 .. $#input;