Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: how to use foreach loop to do comparison between two arrays of hashes

by Laurent_R (Canon)
on Oct 25, 2018 at 23:16 UTC ( [id://1224715]=note: print w/replies, xml ) Need Help??


in reply to how to use foreach loop to do comparison between two arrays of hashes

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.

  • Comment on Re: how to use foreach loop to do comparison between two arrays of hashes

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1224715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-24 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found