in reply to Comparing Dates and Reoccurance

If I understand the problem correctly, I'd make an array of IDs where each element is a hash containing a DateTime (a module you can get from CPAN) and an occurrence count. Then, when you iterate through the input file, you can check the date from the input with the date in the array (at the appropriate ID). The code might look something like this (I haven't tried any of this -- it's off the top of my pointy little head):
use strict; use warnings; use DateTime; my @earliestEvent; open LOGFILE, "<", $filename || die "..."; while (my $input = <LOGFILE>) { my ($dateString, $id) = split / - id = /, $input; my $date = DateTime->new( # use one of the constructors to # fill the date ); if (!exists($earliestEvent[$id])) { $earliestEvent[$id] = {}; $earliestEvent[$id]->{"count"} = 1; $earliestEvent[$id]->{"date"} = $date; } else { my $hourBoundary = $earliestEvent[$id]->{"date"}; $hourBoundary->add(hour=>1); if ($date > $hourBoundary) { print OUTFILE "$id\t" . $earliestEvent[$id]->{"date"}->datetime . "\t" . $earliestEvent[$id]->{"count"} . "\n"; $earliestEvent[$id]->{"count"} = 1; $earliestEvent[$id]->{"date"} = $date; } else { ++{$earliestEvent[$id]->{"count"}}; } } } # then, of course, you'll need to print the remaining ones
Note: DateTime has some idiosyncrasies. You'll probably, for example, want to use the Floating time zone. Does that work for you?