prints:use strict; use Time::Local; my %track; while (<DATA>){ 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); } __DATA__ 2007-Nov-07 00:00:00 - id = 000000001 2007-Nov-07 00:30:01 - id = 000000002 2007-Nov-07 00:40:00 - id = 000000003 2007-Nov-07 01:20:01 - id = 000000001
000000001 2007-Nov-07 01:20:01 2
"As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom
In reply to Re: Comparing Dates and Reoccurance
by NetWallah
in thread Comparing Dates and Reoccurance
by tuakilan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |