in reply to Re: map and grep (but for hashes)
in thread map and grep (but for hashes)

The result of this expression is an array, not a hash. So now we need to combine the values from the keys and produce a hash. The expression is starting to get long (esp. compared with how map and grep look for arrays).

A lot of transformations want me to keep things as hashes. I'd describe most data structures in perl as being multi-level hashes, with a smattering of arrays, not vice versa.

Replies are listed 'Best First'.
Re^3: map and grep (but for hashes)
by runrig (Abbot) on Feb 03, 2009 at 18:43 UTC
    The expression above will return a list of keys. Then getting your filtered hash is as simple as:
    my %new_hash; @new_hash{@filtered_keys} = @old_hash{@filtered_keys};