Welcome to the Monastery. You can update your post to make it more legible: put "<code>" on a line above "order_id, time_mins", and then put "</code>" on the line after the "etc...".

As for your question: it's likely that using a hash of some sort will be useful, but it's not clear what you really need. In your sample, you have two instances of "096000BP" as the "order_id", with time_mins values of "85" and "32". Do you want an output like "096000BP, 53"? What if that order_id value occurs a third (fourth...) time -- what sort of differences should be reported then?

Depending on what you really want, a simple hash might do, or you might need a hash of arrays (for each order_id value, store the list of distinct time_mins values). Something like this will load such a structure, and check for cases where a given hash key occurred multiple times in the data:

my %orders; while (<DATA>) { my ( $id, $mins ) = split /[\s,]+/; push @{$orders{$id}}, $mins if ( $id ); } for my $id ( keys %orders ) { if ( @{$orders{$id}} > 1 ) { my @times = @{$orders{$id}}; # do something with @times } } __DATA__ 096000BN, 32 096000BP, 85 096000BG, 132 096000Be, 85 096000BP, 32
I don't know what you mean by "extremely large". If it's a matter of hundreds of millions of data rows, you might need some sort of "dbm" file as your hash (see AnyDBM_File), or maybe it's time to use a real database.

In reply to Re: Comparing elements of array... by graff
in thread Comparing elements of array... by angelfish

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.