Congratulations AnishaM++. You current code represents a huge leap forward in understanding!

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:

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
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.