t is 15 seconds for my grep method
...but your grep method is only doing half of the work right?
It gets you a big chunk of lines (context) either side of the line containing the search term, but it doesn't restrict them to just the enclosing section you are interested in. So, basically it is only doing half the job. Little wonder that it is quicker?
However, this might be what you're looking for. It gets the time down to 12 seconds on my machine:
#! perl -sw
use strict;
my $term = shift;
$/ = 'Header';
while( <> ) {
chomp;
print 'Header', $_ if 1+index $_, $term;
}
__END__
[11:28:45.37] c:\test>junk34 lima 886391.dat >junk.dat
[11:28:57.83] c:\test>
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|