[ACCEPTED]-Perl - How to find the key of a hash if you know the value?-hash
Accepted answer
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
my ($key) = grep{ $bugs{$_} eq '*value*' } keys %bugs;
print $key;
0
If you aren't using the %bugs
hash for anything 3 else, just modify:
$bugs{$url} = $bug;
to:
$bugs{$bug} = $url;
Then you will have 2 a hash with the correct keys to your query 1 needs.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.