Richie Crews schrieb:
>
> Here my code, I am looking for any way to optimize it so it will read
> these log files slightly faster if possible...
> ...
> foreach $log (@blogs) {
> print "Reading $log\n";
> open(LOG,"$log") or warn "Could not open $log: $!\n";
> while(<LOG>) {
> chomp;
> $line = $_;
> if ($line !~ /^\d/) {
> next;
> } # end of if
Try
while (<LOG>) {
/^\d/ || next;
$line = $_;
...
}
So you can perhaps reduce the assignments $line = $_.
(Well, quite only litte performance)
> my @split = split(/\|/,$line); # making it more managable.
> # Now since voyant sucks and does not use a set column
>system we have
> to go through every split field
> # for the search string... patrol does this too but not as
>clean as
> we will ;)
> #print "$rdate $rtime\n";
> foreach $string (@checks) {
> #print "checking for $string\n";
> if ($split[6] =~ /$string/) {
> print "Ok found $string in $split[6]\n";
> } # end of if
> if ($split[7] =~ /$string/) {
> print "Ok found $string in
>$split[7]\n";
> } #end of if
> } # end of foreach
> } #end of while
> close LOG;
> } # end of foreach
> }
I think you should try put all check strings in one re:
So there's no need for the foreach $string (@checks) loop.
Just write:
my $check_re = qx / \b # Hope, the alarm words are
real words and not part of words
(?=[aABSebdEFIR]) # A look ahead to improve speed
(?=\w\w\w+\b) # another look ahead to improve
speed
(?: alarm |
ASSERTION |
Bus |
... | # it's your job to fill all
possibilities
Retransmitting
)
\b
/;
...
...
if ($split[6] =~ /$check_re/) {
...
}
if ($split[7] =~ /$check_re/) {
...
}
Best Wishes,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]