in reply to Re^7: search array for closest lower and higher number from another array
in thread search array for closest lower and higher number from another array
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: search array for closest lower and higher number from another array
by bigbot (Beadle) on Feb 08, 2011 at 01:27 UTC |