Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: inverting hash / grouping values

by LanX (Canon)
on Sep 27, 2013 at 15:13 UTC ( #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
Node Status?
node history
Node Type: note [id://1055998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-10-02 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (55 votes), past polls