Simple hash search by value
问题 I have a simple hash, and would like to return the $key based on $value criteria. That is, for line 14, what code would I need to return the $key where the $value is "yellow"? 1 #!/usr/bin/perl 2 3 # This program creates a hash then 4 # prints out what is in the hash 5 6 %fruit = ( 7 'apple' => ['red','green'], 8 'kiwi' => 'green', 9 'banana' => 'yellow', 10 ); 11 12 print "The apple is @{$fruit{apple}}.\n"; 13 print "The kiwi is $fruit{kiwi}.\n"; 14 print "What is yellow? "; 回答1: grep is the