cajun has asked for the wisdom of the Perl Monks concerning the following question:
Update Of course the snippet posted above is an over simplification of the problem. Thanks to all for the ideas.#!/usr/bin/perl -w use strict; my $date; my $lastdate = ''; while(<DATA>){ $date = $_; if (($lastdate ne $date) && ($lastdate ne '')){ # print $lastdate report here print "$. $_"; } $lastdate = $date; } __DATA__ 10 10 10 11 11 11 12 12 12
The solution was given in mifflin's code but what drove it home was when GrandFather said "The bug fix is to let the while loop run one more itteration after finding the end of the file."
I'm parsing maillog files to produce a SpamAssassin report. I foolishly started with someone elses code that did not work, did not use strict, did not use warnings.. I would have been better off I think to do the whole thing from scratch.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing log files
by mifflin (Curate) on Jun 28, 2005 at 03:01 UTC | |
|
Re: Parsing log files
by GrandFather (Saint) on Jun 28, 2005 at 03:33 UTC | |
|
Re: Parsing log files
by tlm (Prior) on Jun 28, 2005 at 03:02 UTC |