use List::Util qw( first ); my $idx = first { $array[$_] eq "string" } 0..$#array;