modi2020 has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys, In the example below I create a hash with names as values and phone numbers as keys:
I can extract the phone number of say Shirly by phoneNumber=$phoneDirectory{"Shirly"}; What if Shirly had more than one number. Is there a way to extract all her phone numbers by using her name as a key? Now,Suppose I have the following file:my % phoneDirectory=( ‘Shirly’=>‘7267975’, ‘Michael’=>‘5243755’, ‘Fred’=>‘1294874’, );
I want to be able to read the file into a has of hash and I want to be able to retrieve all elements under a key. For example I want to be able to say print $hash{John} and get Marry, Lea, Paul. Is that possible?John Marry John Lea John Paul David Patrik David Sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing hash values in a HOH
by Plankton (Vicar) on Feb 23, 2013 at 05:46 UTC | |
|
Re: Accessing hash values in a HOH
by space_monk (Chaplain) on Feb 23, 2013 at 06:34 UTC | |
by Athanasius (Archbishop) on Feb 23, 2013 at 07:04 UTC | |
by modi2020 (Novice) on Feb 23, 2013 at 16:06 UTC |