First, try just a null reading loop in perl - this will give you a lower bound on what the Perl can be optimised to:
while (<FILE>) { }
If this isn't fast enough, then you'll definitely have to use something other than Perl, at least for the initial filtering. If it is fast enough, then the next thing is to reject unwanted lines as quickly as possible. You probably want to do that with a single pre-compiled regexp:

my $re = qr/^$year-.{21} IP (?:\Q$IP1\E > \Q$IP2\E|\Q$IP2\E > \Q$IP1\E +/; while (<FILE>) { next unless /$re/; ... do something ... }

The exact form of the pattern will depend on how flexible the the 1st line of each entry is, e.g. whether it uses a fixed number of digits for the sub-seconds value

Dave.


In reply to Re: Parsing Large Text Files For Performance by dave_the_m
in thread Parsing Large Text Files For Performance by bigbot

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.