legendx has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I have been hacking away at getting a solution to the below problem but just cant seem to get it to work and would appreciate some help, please!
Below is a sample hash structure that I am working with.
I am trying to compare all the values in the 'myStr' of each hash key ID (ID1, ID2, ID3) to the 'yourStr' values of other ID keys and simply print the 'ID' or 'description' of matches.
Sort of like:
Loop through the hash keys i.e. ID1, ID2, ID3
foreach ID1
then check if the 'myStr' in ID1 matches the 'yourStr' ID2, ID3, etc..
Also, please note that the 'yourStr' values are in an array in the hash
Any ideas or help would be greatly appreciated!
$VAR1 = { 'ID1' => { 'myStr' => 'hello', 'description' => 'Description 1', 'yourStr' => [ 'goodbye', 'where' ] }, 'ID2' => { 'myStr' => 'good', 'description' => 'Description 2', 'yourStr' => [ 'hello', ] }, 'ID3' => { 'myStr' => 'testvar', 'description' => 'Description 2', 'yourStr' => [ 'hello', 'good' ] }, };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing values in same hash?
by Marshall (Canon) on Jul 22, 2011 at 16:58 UTC | |
by legendx (Acolyte) on Jul 24, 2011 at 17:20 UTC | |
|
Re: Comparing values in same hash?
by Not_a_Number (Prior) on Jul 22, 2011 at 17:59 UTC | |
by legendx (Acolyte) on Jul 24, 2011 at 17:27 UTC | |
|
Re: Comparing values in same hash?
by Anonymous Monk on Jul 22, 2011 at 20:28 UTC |