foreach my $thing (@array) { foreach ((my $key, my $value) = each %hash) { if ($key == $thing) { push @new_array, $value; } } }