Filter arry

From: Freddy Drogt (f.drogt-nosp_at_sze.nl)
Date: 01/29/04


Date: Thu, 29 Jan 2004 09:58:59 +0100

Hello,

I have a logfile and I want to make statistics of it. I have my logfile put
i a array and ech ellement of the array is a virus detection. I want to
create a log in the follow format: month: XXX detectet virus: 999.

How can I solve this in PERL:

Logfile part which is a ellement in a array:

 Wed Jan 28 15:22:33 2004
  Sender: <jack@xx>
  Recipient list: <sandra@yy>
  MessageID: 10752997486
  Virus: W32/Mydoom@MM
  Action: Deleted and Quarantined
  Partfile: doc.zip

My current script to put each virusevent in a ellement of a array:
open (logfile, "c:/temp/log-antivirus/log.log") or die "Fout!...:$!\n";
 while (<logfile>)
{
$string .= $_;
}
@array = split(/\n{2,}/, $string); # opsplitsen logfile op lege regels
print $array[1]; #print one virusdetection
#print "\n\@array has " . ($#array + 1) . " elements.";



Relevant Pages

  • Re: Can this be more efficient?
    ... Colin chaplin wrote: ... > For each logfile in the directory: ... > read into an @rray ... > for each line of array ...
    (comp.lang.perl.misc)
  • Re: Perl Expect send array
    ... ruud wrote in comp.lang.perl.misc: ... > I am reading the whole logfile into an array: ...
    (comp.lang.perl.misc)
  • Counting elements in array
    ... How can I count the number of different elements in an array. ... Some other virus = 24 ... open(LOGFILE, "<$logfile") ... print @vir; ...
    (comp.lang.perl.misc)
  • Perl Expect send array
    ... I am having a logfile called "log". ... I am reading the whole logfile into an array: ... i get the correct output. ...
    (comp.lang.perl.misc)