Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: map and grep (but for hashes) (List::Pairwise)

by lodin (Hermit)
on Jan 31, 2009 at 11:59 UTC ( [id://740410]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://740410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found