Here's some simple code to (hopefully) start you in the right direction.
---
$logsPath = "D:\\John\\Scripts";
opendir LOGDIR, $logsPath or die "Can't open $logsPath";
@allFiles = readdir LOGDIR;
closedir LOGDIR;
foreach $file(@allFiles) {
push(@logFiles,"$logsPath\\$file") if -T "$logsPath\\$file";
}
foreach $logFile(@logFiles) {
print "Processing logfile $logFile\n";
open CURRENTLOG, $logFile or die "Can't open $logFile";
while (<CURRENTLOG>) {
if (/print/ig) {
$prints++;
}
}
close CURRENTLOG;
}
print $prints;
---
Some notes about the code, it's quick and dirty. There are more than likely
many better ways of doing the above. It's just a starter. All it does is
count the number of times the word print appears in all of the textfiles in
the directory specified. It does not include any subdirs below the directory
specified.
Anyway, hope this gets you started.
John
-----Original Message-----
From: Ronald J. Yacketta [mailto:[EMAIL PROTECTED]]
Sent: 15 June 2001 00:07
To: Perl
Subject: major "I have no clue" here
I have been tasked to parse ~1500 log files summing a total of ~100mb
cleanly, effectively and with little impact on the system.
The current process uses a korn shell and greps ALL ~1500 files or certain
patterns and sends the output to another file were later in the script it is
greped again! WOW talk about ugly! timex on this process during SLT (System
Load Tests) had it jumping from ~0.30 to ~15.32!! holy be Jesus!
I want to redo this in perl, maybe thread it? maybe parse #logs / 3 at a
time? thus throwing the 3 greps on 3 different cpus, hopefully reducing
overhead etc..
What are some recommendations? I am a novice at best at perl. If you have a
recommendation could you possible post some starter code? I can handle the
regex and parsing.. just not sure how to handle the HUGE number and SIZE of
the files cleanly, effectively and with minimal system impact
Regards,
Ron
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.