in reply to Monk Specs.?
Just read the records one at a time, and when you encounter the date you are looking for, start writing to the other log file
my $found_date = 0; while( <LOG> ) { $found_date = 1 if /$date/o; print LOGFILE if $found_date; }
I think that even if you don't find the date, your script as it stands will still write the last line to second file. I can't decide whether that is a bug or a feature... if the latter, then you should print LOGFILE unless $found_date after the end of the while loop.
Note that saying print LOGFILE is the same as saying print LOGFILE $_ (the $_ is implied). In any event, you don't need to quote $_.
--
|
---|