my @new_array; while (my ($key, $value) = each %hash) { push @new_array, $key if (grep { /^$value$/ } @array); } __END__ $VAR1 = [ '2', '1' ];