2008-Jan-01 00:00:00 UTC (GMT +0000) - Toll: channel = seven, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 123456789
2008-Jan-01 00:10:00 UTC (GMT +0000) - Toll: channel = six, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 987654321
2008-Jan-01 00:20:00 UTC (GMT +0000) - Toll: channel = three, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 223344221
2008-Jan-01 00:30:00 UTC (GMT +0000) - Toll: channel = four, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 998829992
2008-Jan-01 00:40:00 UTC (GMT +0000) - Toll: channel = three, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 938874724
2008-Jan-01 00:50:00 UTC (GMT +0000) - Toll: channel = two, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 229928828
2008-Jan-01 01:00:00 UTC (GMT +0000) - Toll: channel = five, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 998822992
2008-Jan-01 01:10:00 UTC (GMT +0000) - Toll: channel = seven, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxx, tids = 123456789
####
TIDS time Occurance
====================================================
123456789 2008-Jan-01 01:10:00 2
####
#!/usr/local/bin/perl -w
use strict;
use warnings;
use Time::Local;
my $infile = 'input.2008-01-01.log';
my $outfile = 'output.2008-01-01.log';
my($fh_out, $fh);
open($fh_out, '>', $outfile) or die "Could not open outfile: $!";
open($fh, '<', $infile) or die "Could not open logfile: $!";
my %track;
while (<$fh>){
my ($date,$ignoreIDLiteral,$id) = split / - | = /;
chomp $id;
my $time = dateconv($date);
my $prevtime = $track{$id}{TIME};
$track{$id}{TIME}=$time;
$track{$id}{DATE}=$date;
$track{$id}{COUNT}++;
print "$id\t$date\t$track{$id}{COUNT}\n"
if $prevtime and $time - $prevtime > 3600;
}
sub dateconv{
my $d = shift;
my %month = qw[jan 1 feb 2 mar 3 apr 4 may 5 jun 6 jul 7
aug 8 sep 9 oct 10 nov 11 dec 12];
my @p = $d=~/(\d+)-(\w+)-(\d+)\s(\d+):(\d+):(\d+)/;
$p[1]=$month{ lc $p[1] } - 1;
return timelocal(@p[5,4,3,2,1,0]);
#timelocal($sec,$min,$hour,$mday,$mon,$year);
}
close $fh_out;
close $fh;