Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: inverting hash / grouping values

by LanX (Saint)
on Sep 27, 2013 at 15:13 UTC ( [id://1055998]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      DB<100> use Hash::MoreUtils qw/safe_reverse/
    
    ...
    
      DB<106> safe_reverse \%h
     => (1, ["a", "b"], 2, "c")
    
  2. or download this
      DB<110> safe_reverse sub { my ($k, $v, $r) = @_; return [ @{$r->{$v}
    +}, $k ] },\%h
     => (1, ["a", "b"], 2, ["c"])
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found