"Elizabeth A. Rice" wrote: > > I am trying to find the first occurrance of a date string in several > different files in order to re-write all of today's entries back into the > existing log file after taking out all the old entries to be archived. (I > also realize lots of folks have done this and I'm sure come up with much > easier ways to do it.) In our case each log entry is three lines long, only > the first line has the date in it. > > I would like to use the same script for each file, however the date format > is slightly different in one of them. In some files the date will have a > leading zero, in others it will not. > It can be: > Wed Apr 3 or Wed Apr 03 > > What I've written so far.... > > @ARGV = ("$logfile"); # prime the diamond operator ^^ ^^ Useless use of quotation marks and parenthesis.
@ARGV = $logfile; > $¬I = ".bak"; # write $logfile.bak for backup > while (<>) { > if ($todayfound eq "y") { # IF today's date has already been > found > print; # write to ARGVOUT, the new logfile > # date format varies. > # Usually: Tue Apr 2 > # could also be: Tue Apr 02 > # IF today's date found for first > time... > } elsif (m/($weekday\s)($month\s+)(0?$day)/o) { > $todayfound="y"; # change flag > print; # write to ARGVOUT, the new logfile > } else { # IF we have not reached today's date > print LOGCOPY; # write the line to the logcopy file > s#.*\n##; # erase the line in ARGVOUT, the new > logfile > } > } This is how I would do it (YMMV) (untested) elsif ( /(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+ (\d+)/x and $1 eq $weekday and $2 eq $month and $3 == $day ) { $todayfound = 'y'; # change flag print; # write to ARGVOUT, the new logfile } else { # IF we have not reached today's date John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]