raj8 has asked for the wisdom of the Perl Monks concerning the following question:
Example: Log File Line Containing Date [1/21/2008 4:33 AM] API call error
print "\n"; print "======================================\n"; $aDate = &get_cur_time; print "=====================================\n"; open(FH, "c:\sync.log") || die "Cannot open Log:$!\n"; while (<FH>) { if ($aDate) { print "ERROR\n"; } }; close(FILE); print "\n"; ### Getting a time format for printing ### sub get_cur_time { my $Second; my $Minute; my $Hour; my $Day; my $Month; my $Year; my $WeekDay; my $DayOfYear; my $IsDST; ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); my $RealMonth = $Month + 1; $RealMonth = "0" . $RealMonth if($RealMonth < 10); $Day = "0" . $Day if($Day < 10); $Hour = "0" . $Hour if($Hour < 10); $Minute = "0" . $Minute if($Minute < 10); $Second = "0" . $Second if($Second < 10); my $Fixed_Year = $Year + 1900; ### Making Date Format For Files ### #return "$RealMonth$Day$Fixed_Year"; ### Different Format ### print "Today's Date is: $RealMonth/$Day/$Fixed_Year $Hour:$Minute:$Sec +ond\n"; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading log file for current date
by hipowls (Curate) on Jan 25, 2008 at 21:57 UTC | |
|
Re: Reading log file for current date
by toolic (Bishop) on Jan 25, 2008 at 22:09 UTC | |
|
Re: Reading log file for current date
by toolic (Bishop) on Jan 25, 2008 at 21:53 UTC | |
by raj8 (Sexton) on Feb 24, 2008 at 01:45 UTC | |
|
Re: Reading log file for current date
by pc88mxer (Vicar) on Jan 26, 2008 at 06:01 UTC |