Advertisement

05.24.2007 at 06:21AM PDT, ID: 22592309
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

perl datetime format issue

Asked by NickUpson in Miscellaneous Programming, Unix Systems Programming, Perl Programming Language

Tags: ,

I'm trying to parse a logfile and where the difference between consecutive rows is more than 'x' seconds, print both rows

the files are in the format:
02.04.07 10:12:26 TDD1  process started
02.04.07 10:14:23 TDD9  process terminating (OK)
02.04.07 10:16:04 TDD1  process started
02.04.07 10:18:07 TDD9  process terminating (OK)
02.04.07 10:18:08 TDD1  process started
02.04.07 13:57:18 TDD9  process terminating (OK)

here is what I have so far (mostly from a collegue)

#!/usr/bin/perl
#
# Find if timediff between lines exceeds N seconds
#

use HTTP::Date;

my $tdif = 5;
if ( ! -f @ARGV[0] ) {
  $tdif = shift @ARGV;
}

my $p_line = "";
my $p_time = 0;

# Parse files
while ( <> ) {

  # Only accept good lines
  if ( /(\w+\s+\w+\s+\d+\s+\d\d:\d\d:\d\d\s+\d+)/ ) {
    my $c_time = HTTP::Date::str2time($1);

    # Compare
    if ( $p_line ne "" ) {
      if ( ($c_time - $p_time) > $tdif ) {
        print "$p_line";
        print "$_";
        print "\n";
      }
    }

    # Update
    $p_line = $_;
    $p_time = $c_time;
  }
}

I get no outputStart Free Trial
[+][-]05.24.2007 at 07:42AM PDT, ID: 19149613

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2007 at 07:50AM PDT, ID: 19149695

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.24.2007 at 08:45AM PDT, ID: 19150175

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2007 at 08:46AM PDT, ID: 19150191

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2007 at 10:27AM PDT, ID: 19151115

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.24.2007 at 10:50AM PDT, ID: 19151281

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2007 at 01:07AM PDT, ID: 19155323

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2007 at 02:39AM PDT, ID: 19155627

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2007 at 07:49AM PDT, ID: 19157314

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Miscellaneous Programming, Unix Systems Programming, Perl Programming Language
Tags: perl, datetime
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44