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

Re: Swapping keys and values in a hash with slices

by tomhukins (Curate)
on Oct 20, 2004 at 10:31 UTC ( #400808=note: print w/ replies, xml ) Need Help??


in reply to Swapping keys and values in a hash with slices

This seems reasonable enough to me, with the usual caveat that you will lose information if multiple elements share the same value.

I would never use this code in production, though. You mention other solutions using loops and map, but I find the %revhash = reverse %hash idiom more elegant.


Comment on Re: Swapping keys and values in a hash with slices
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-07-02 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls