I have a question....How can I compare two different times' but skip skip any lines that have text? Every 10 seconds a ping is sent out. For any time greater than 10 seconds I want to document that a packet was lost. The file contains headers for every 5 minutes. The problem is that whenever it comes across a header, it makes it look like a packet was lost. Any suggestions? My code is below. Thanks in advance.
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

In reply to Skip header text when comparing time by ITmajor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.