use List::Util qw(first);$idx = first { $array[$_] eq 'whatever' } 0..$#array;
(List :: Util是核心)
要么
use List::MoreUtils qw(firstidx);$idx = firstidx { $_ eq 'whatever' } @array;
(List :: MoreUtils在CPAN上)