in reply to Obtain Key from Hash using value
I would loop through the keys and put a conditional to check to see if the value for that key is what you want.
#assume that %hash has been defined #assume that $value_to_find has been defined foreach my $key (keys %hash) { #use == instead of eq if numeric value if ($hash{$key} eq $value_to_find) { #$key is the key you were looking for print "$key has the value: $value_to_find\n"; } }
|
|---|