[ACCEPTED]-Perl - How to find the key of a hash if you know the value?-hash

Accepted answer
Score: 10

You can make an inverted copy of your original 4 hash with reverse operator and then make a "normal" lookup 3 (would work properly only if values in original 2 hash are unique).

More on this topic including 1 handling duplicate values at perlfaq4: How do I look up a hash element by value

Score: 9
my ($key) = grep{ $bugs{$_} eq '*value*' } keys %bugs;
print $key;


Score: 3

If you aren't using the %bugs hash for anything 3 else, just modify:

$bugs{$url} = $bug;


$bugs{$bug} = $url;

Then you will have 2 a hash with the correct keys to your query 1 needs.

More Related questions