use List::Util qw( first ); my $idx = first { $repo[ $_ ] eq 'bar' } 0..$#repo;