Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Getting Keys of Hash from Valuesby tmoertel (Chaplain) |
on Nov 16, 2005 at 21:20 UTC ( [id://509203]=note: print w/replies, xml ) | Need Help?? |
On the subject of inverting hashes, you can invert a hash via reverse like so:
To see the results, we can use Data::Dumper: As you note, however, not all hashes have one-to-one mappings to their inverted forms. In such a case the inverted form will have fewer key-value pairs than the original hash: You can use this property to test whether you have lost information during inversion:
Cheers, Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
In Section
Seekers of Perl Wisdom
|
|