http://qs321.pair.com?node_id=740410


in reply to map and grep (but for hashes)

Does the grepp and mapp functions in List::Pairwise do what you want? $a and $b is used for the keys and the values. The synopsis shows some simple examples.

I'm also a fan of using pair (from the same module) when suitable, and in particular when I need to sort the data. I often use a hash when I really want a list of tuples. pair gives me that and when I want to use e.g. grep I simply use $_->[0] for the key and $_->[1] for the value. No extra magic needed. If I want to turn it into a hash-like list I simply do map @$_, .... (Using pair can be excessively memory consuming though. mapp should not suffer from that.)

lodin