![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Re: virus log parserby Rhose (Priest) |
on Jul 02, 2002 at 20:44 UTC ( #178995=note: print w/replies, xml ) | Need Help?? |
How about collecting the information, then printing the record when you get to one of the '-----' lines? (This assumes all records -- even the last one -- end with a '-----' line.)
The following code reads from __DATA__ and writes its (tab delimited) records to the screen; you would probably want to open your log file for processing (open(LF,"$logFile")), and write to a results file (open(OF,">$outputFile")).
Comment: One other thing I found I like is opening files with three parameters. For example, instead of: open(OF,">$outputFile") || die; I use: open(OF,'>',$outputFile) || die; I hope this helps! *Smiles* Update: Now that I have re-read my code, I should have made qw(name to file action virus) a constant so it was defined but one place, and should have made the field separator a constant as well. This would simplify changes to the code. (Not that it is critical on such a small program, but it is a good practice... well, for me at least.)
In Section
Seekers of Perl Wisdom
|
|