Greetings:
I have 2 large data sets contained in arrays. Respectively, the sets contain about 30,000 and 100,000 elements. The elements each consist of an identifier and a timestamp delimited by a pipe.
example:
Set 1 (@data): g123|10249875 g948|32004040 Set 2 (@ref): g123:1|10249870 g123:2|10249875 g123:3|10249871 g984:2|94950595 g984:1|32004040
My task is to create a list of identifiers from set 2 where the datestamp is not equal to the corresponding stamp in set 1. This is my code:
foreach $elem(@data){ ($sub,$max)=split/\|/,$elem; @found=grep /^$sub:/,@ref; foreach $f(@found){ ($id,$time)=split/\|/,$f; if($time ne $max){ push @set,$id; } } }
...And the id's I am looking for end up in @set:
@set: g123:1 g123:3 g984:2
Sadly, this method is prohibitively slow. I am looking for suggestions on how to make this process more efficient.
Thanks in advance,
Jason

In reply to Large Set Efficiency Question by insensate

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.