++AnishaM: Good progress. From reading your original question, the results you show are what I thought you wanted. Given that you don't seem happy with those results, here are further ideas

but it compares each key of every Hash in structure1 with each key of every Hash in structure2

friendly pedant mode: Technically, for every row (subhash) of the first array and for every row (subhash) of the second array, you are comparing the value of each key in the first subhash to the value of the same key of the second subhash, for a total of 5*5*3=75 comparisons. If you were really comparing the value of every key of each subhash (ie, comparing name to 'name', 'time', and 'place', etc), it would be 5*5*3*3=225 comparisons.

If you really only want to compare the first row of HOAOH1 with the first row of HOAOH2, the second row with the second row, etc (for a total of 5 outer comparisons and 3 key comparisons = 25), here's a hint: since you want the row# to match for each subhash that's compared, you might want to collapse the arrayItem1 and arrayItem2 loops into a single loop that gives an index, and then use that index to find the appropriate row from each HOAOH#

I would also recommend printing something during the FALSE condition of your compare, as well, so that you can see better what's going on and how many loops are being executed. You might want to add the outer loop variables to your print statements (whether they be references, indexes, or what have you), so that way you can tell exactly which pairs are being compared.


update 1: reword the pedant-mode to be more pedantically correct (100% correctness not guaranteed). :-)

update 2: fix brackets to parenthesis in update 1


In reply to Re^3: Compare array of hashes by pryrt
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.