my %index_map = map { $array[$_] => $_ } 0..$#array; # Associate each element with its index (only works for unique values though) my @matching_indexes = map { $index_map{$_} } @subset; # Get the index for each value in @subset