http://qs321.pair.com?node_id=681103


in reply to getting hash key with value

This is trivial using List::Pairwise, even if the values aren't unique.

use List::Pairwise 'mapp'; my %hash = ( foo => 1, bar => 2, baz => 1, bux => 0, ); my $val = $hash{foo}; my @keys = mapp { $b eq $val ? $a : () } %hash; print "@keys"; __END__ baz foo
Even if you think that your values are unique it's sometimes a good idea to assert this:
my ($key, @too_many) = mapp { $b eq $val ? $a : () } %hash; ! @too_many or die 'Too many ...';

lodin