in reply to Re: comb a logfile for time diff and occourance
in thread comb a logfile for time diff and occourance

That won't work: the time difference must be more than one hour.

Also you use $date as a key to your hash, but you never put anything in it. You probably meant $time.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^3: comb a logfile for time diff and occourance
by hipowls (Curate) on Feb 18, 2008 at 11:21 UTC

    Thanks for catching the typo, I've corrected the original post.

    You are right to some extent, I'd missed the bit about identical refs. However the specs aren't clear and it is not obvious what the OP really wants to report.

    A modification of the code to

    while ( my $line = <$file> ) { next unless $line =~ /TWO/; my ($time, $ref) = $line =~ /^(\d\d\d\d-\w\w\w-\d\d \d\d)/).*refs += (\d+)$/; ++$stats{$time}{$ref}; }
    may suffice. It will keep a count of how many times each ref number occurs during each hour. Typically data is reported over fixed intervals of time and this approach certainly has the advantage of simplicity.

      "Lack of clear specifications" is probably the worst part of having to implement something for someone else. Rarely they have a clear view of what they want, but that of course will not stop them from changing their targets and blaming the programmers if projects overrun their allowed budgets of time and money.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James