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' ] }, };
In reply to Comparing values in same hash? by legendx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |