use List::MoreUtils qw(firstidx); my $index = firstidx { $_ == $searchvalue } @array;