A few nits, @{$$HOAOH1{details}}... Usually the de-referencing operator "->" would be preferred over the double "$$". This code means exactly the same thing and many would find this easier to read:
I also had to add quotes around 'AB", 'IJ', etc. in order to make "strict" happy. An assignment that doesn't compile under strict is unusual. use strict; use warnings; will save you a lot of grief in the future. I highly recommend that.foreach my $arrayItem1(@{$HOAOH1->{details}}) { foreach my $arrayItem2(@{$HOAOH2->{details}}) { foreach my $keyArrayItem1(sort keys %$arrayItem1) { if ($arrayItem1->{$keyArrayItem1} eq $arrayItem2->{$keyArr +ayItem1}) { print "Match:$arrayItem1->{$keyArrayItem1} $arrayItem2 +->{$keyArrayItem1}\n"; } } } } __END__ Match:AB AB Match:1234 1234 Match:CD CD Match:5678 5678 Match:EF EF Match:91011 91011 Match:GH GH Match:121314 121314 Match:cccc cccc Match:IJ IJ Match:151617 151617
The code contains a mixture of tabs and spaces. I think as you write more code, you will find that spaces only are the way to go. My tab isn't the same as your tab, etc. Editors designed for writing programs will have a setting "convert tabs to spaces". That makes everything clear and the extra bytes for the spaces vs a tab is meaningless.
Looking at the output, it is hard for me to figure out what records are involved when something matches/doesn't match. pryrt has some suggestions in that regard. I'd re-read the text of the assignment closely to see if there is some clue about what the instructor wants in terms of output format.
In reply to Re^3: Compare array of hashes
by Marshall
in thread Compare array of hashes
by AnishaM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |