I am looking for search implementation on hash using perl. I have following data in my hash
%hash = {0 => "Hello", 1=> "world"}.
Now i want to search the hash using the values (means world and hello) and return corresponding key.
Example: I want to search for world and the result should be 1
Iterate of the keys of the hash with a
for ( keys %hash ) ...statement and check the values as you go. If you find what you are looking for, returnanother option would be to use
while ( ... each ... )the use of
{ }literal creates a hash reference and not a hashto create a literal hash you use
( )execution of
while ... eachon hashref