Hi,

first, concerning your code, I would suggest that you format your code correctly (with consistent indenting), especially for such deeply nested loops and conditionals. I am just unable to read you code as currently formatted. That would certainly help you understand what you're doing (and possibly what you're doing wrong). Granted, I could reformat it myself or run it through a prettyfier, but, sorry, I don't see why I should do that if you're too lazy to do it yourself and show us proper code. Similarly, I don't know what your data is, but using better names for your variables and hash keys might also help making sense out of your data structure.

Second, it seems to me that your choice of data structure is quite poor (too complicated) for your needs (but that may be because you've shown us dummy data). Looking at your data, I would store your files into something simpler, such as an array of lines for each company (so, overall, a hash of arrays). Then I would compare full lines and remove (and print out) any matching line. In the end, with the data you've shown, you would end up with two lines not matching for Adidas. Now, of course, we don't know enough about your data to know how to deal with the fact that the two Adidas lines appear not to be in the same order; you would have to provide additional information on how we can figure that out.


In reply to Re: how to use foreach loop to do comparison between two arrays of hashes by Laurent_R
in thread how to use foreach loop to do comparison between two arrays of hashes by darkmoon

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.