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: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);
I use index here, because it's faster than matches.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}, $_; }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |