This produces the required output but I'm not convinced that it does what is required.

Anyway they're not my problems, I had fun with the regex;-)
#!/net/perl/5.10.0/bin/perl use strict; use warnings; use 5.010_000; use DateTime::Format::Strptime; use Readonly; Readonly my $delta => 60 * 60; my %stats; my $log_parser = qr{ \A (?<time_stamp> \d{4}-\p{IsAlpha}{3}-\d\d [ ] \d\d:\d\d:\d\d ) .* [ ] - [ ] id [ ] = [ ] (?<id> \d+ ), [ ] Status [ ] = [ ] (?<status> \w+ ) }msx; my $date_parser = new DateTime::Format::Strptime( pattern => '%Y-%b-%d %T', on_error => 'croak', ) or die "Can't create date parser: $!\n"; while ( my $line = <DATA> ) { if ( $line =~ /$log_parser/ ) { my ( $time_stamp, $id, $status ) = @+{qw(time_stamp id status) +}; next if $status eq 'success'; my $date = $date_parser->parse_datetime($time_stamp); || $stats{$id}[-1][0]->subtract_datetime_absolute($date)-> +seconds > $delta ) { push @{ $stats{$id} }, [ $date, $time_stamp, 0 ]; } else { ++$stats{$id}[-1][2]; } } } if ( scalar keys %stats ) { say 'ID last attempted attempts'; say '=' x 44; foreach my $id ( sort keys %stats ) { foreach my $time ( @{ $stats{$id} } ) { printf "%s %s %8d\n", $id, @{$time}[ 1, 2 ]; } } } __DATA__ 2008-Feb-01 00:00:02 UTC (GMT +0000) - id = 000000001, Status = failed 2008-Feb-01 00:10:02 UTC (GMT +0000) - id = 000000002, Status = succes +s 2008-Feb-01 00:20:02 UTC (GMT +0000) - id = 000000003, Status = failed 2008-Feb-01 00:30:02 UTC (GMT +0000) - id = 000000004, Status = succes +s 2008-Feb-01 00:40:02 UTC (GMT +0000) - id = 000000001, Status = succes +s 2008-Feb-01 00:50:02 UTC (GMT +0000) - id = 000000001, Status = succes +s 2008-Feb-01 01:00:02 UTC (GMT +0000) - id = 000000001, Status = failed 2008-Feb-01 01:10:02 UTC (GMT +0000) - id = 000000007, Status = succes +s 2008-Feb-01 01:20:02 UTC (GMT +0000) - id = 000000003, Status = failed 2008-Feb-01 01:30:02 UTC (GMT +0000) - id = 000000009, Status = succes +s
Output
ID last attempted attempts ============================================ 000000001 2008-Feb-01 00:00:02 1 000000003 2008-Feb-01 00:20:02 1


In reply to Re: Logfile analysis : How to differentiate records with timestamp by hipowls
in thread Logfile analysis : How to differentiate records with timestamp by tuakilan

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.