This is a nice one. I would take another approach. The 65,000 is not really a problem with decent memory, so I would just read all in one swoop:
use SuperSplit; $AoA = supersplit_open('|','\n',$filename); no strict; for $line ( @AoA ){ $ecl_hash->{$line[0]}->{$line[1]}->{$line[2]}=@line[3..$#line]; } my $sub_ecl = $ecl_hash->{$NETID}->{$date}; some_function( $sub_ecl->{$time} ) for $time (keys %$sub_ecl);
This prevents you from grepping every item of your timearray, which takes quite some time indeed. The above returns something easy to process, but if you want more speed, the following is better and doesn't use supersplit:
open DATA, $filename; my %ecl_hash; my $str = "$NETID|$month/$date/$year"; while( <DATA> ){ next if index($_,$str)<0; chomp; my $item = (split '|' )[2]; $ecl_hash{$item} = [] unless defined $ecl_hash{$item}; push @$ecl_hash{$item}, $_; }
I use index here, because it's faster than matches.

Returns something similar, only the fields have not been separated into arrays. But maybe you don't even want to.

SuperSplit can be found here.

Cheers,

Jeroen
"We are not alone"(FZ)

Update: I ignored the fact that you want to search on the date/ID as well. Fixed in the last codeblock. Will be much faster, of course. What do you *really* want? You want to add an extra line to a report, with some sumary? You wanna make some graphs? Depending on the question, you can decide whether you want the whole thing read in, or just a little piece, or whether you'd better go and put everything in a database, as merlyn suggested...

Update2: after quite some CB, I think ImpalaSS'd better use the supersplit method and use the modified hash to access his data.


In reply to Re: Grep Speeds by jeroenes
in thread Grep Speeds by ImpalaSS

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.