in reply to Re: Comparing Dates and Reoccurance - Part II
in thread Comparing Dates and Reoccurance - Part II

hi dwm, i edited your code to the below and when i ran it with root profile, still reply the header alone and without much info :(

#!/usr/local/bin/perl -w use strict; use warnings; use Time::Local; my $debug = shift || 0; my $header = 0; my $infile = 'tollog-2007-jan-01.txt'; my $outfile = 'report-2007-01-01.txt'; my($fh_out, $fh); open($fh, '<', $infile) or die "Could not open logfile: $!"; open($fh_out, '>', $outfile) or die "Could not open outfile: $!"; my %track; while (<$fh>){ my ($date,$ignoreIDLiteral,$id) = split / - | id = /; if ( $debug ) { print "Date = $date\n"; print "Literal = $ignoreIDLiteral\n"; print "ID = $id\n"; } chomp $id; my $time = dateconv($date); my $prevtime = $track{$id}{TIME}; $track{$id}{TIME}=$time; $track{$id}{DATE}=$date; $track{$id}{COUNT}++; if ( $prevtime and ( $time - $prevtime > 3600 ) ) { unless ( $header ) { print "TIDS TIME OCCURANCE\ +n"; print "====================================================\ +n"; $header = 1; } print "$id\t$date\t$track{$id}{COUNT}\n" } } 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]); } close $fh_out;

by the way, what does $ignoreIDLiteral to mean over here ? does the ID refers to the ID field in the source data ?