|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Re: Comparing values in same hash?by Not_a_Number (Parson) |
| on Jul 22, 2011 at 17:59 UTC ( #916178=note: print w/ replies, xml ) | Need Help?? |
|
Here's my solution, probably a little more complex than Marshall's above. It does two passes over the hash. In the first pass, it builds a HoA where the keys are the all the words from 'yourStr' and the values are arrays holding the IDs concerned, which ends up looking like this:
On the second pass, it checks if the value of 'myStr' is in the HoA, and prints out any matches, excluding 'internal' matches (ie if for the same ID 'hello' were to appear in both 'myStr' and 'yourStr').
Output:
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||