http://www.perlmonks.org?node_id=601996


in reply to Re^2: Hash assignments using map
in thread Hash assignments using map

Right. My point is, why not loop over the elements in @keepers, rather than the keys of the other hash?
my %big_hash = (...); my @to_keep = ('abc', 'xyz'); %big_hash = map { exists($big_hash{$_}) ? ($_ => $big_hash{$_}) : () } + @to_keep; # or %big_hash = map { $_ => $big_hash{$_} } grep { exists $big_hash{$_} } +@to_keep;

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart