ITmajor has asked for the wisdom of the Perl Monks concerning the following question:
foreach my $line (<FILE>) { # Do following for each line infile chomp $line; if ($line =~ /^\b\d/){ # Skip lines that contain text ($timestamp, undef, $out, undef, undef, undef, $in, undef)=split(/\t/, + $line); # Sort out needed columns my $seconds = ($timestamp - $last_time); # Determine elapsed time if ($seconds > .00012){ # For time longer than 10 seconds my $time = DateTime::Format::Excel->parse_datetime($timestamp); # For +mat time/date my $logdate = $time->ymd; # Date format my $logtime = $time->hms; # Time format my $error_name = "$center Error Log $log_time"; open(PACKETS,">> /directory/logs/error_log.txt"); print PACKETS "Packet lost on $logdate at $logtime\n" or die "Can't op +en file $!"; # Write to log file } $last_time = $timestamp; # Store as previous time to compare
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Skip header text when comparing time
by Osiris1975 (Novice) on Jan 15, 2009 at 20:52 UTC | |
by ITmajor (Beadle) on Jan 20, 2009 at 21:15 UTC | |
by Osiris1975 (Novice) on Jan 21, 2009 at 14:52 UTC |