> Have a look at the sample data you posted and you will see where.
> 
> 
> John

I believe I found where the ']' needs to go but didn't see any extra ' '
space.

The $x count seems off. As I see it every time a regex match is made then $x
will increase one. The match numbers results are about 5x greater then what
they should be after correlating my grep findings with the perl output.

my ( %srca, %quad, %port );
my $x;

while (<LOG>) {
        next unless
/Sig:\s*(\d+)\s+Subsig:\s*(\d+)\s+Sev:\s*(\d+)([^\[]+)\[([\d\.]+):(\d+)\s*->
\s*([\d\.]+):(\d+)\]/;
        $x++;
        $srca{ $5 } += $x;
        $quad{ sprintf '%-16s -> %-16s Port %-6s %-s', $5, $7, $8, $4 } +=
$x;
#       $port{ sprintf 'port %-6s %-16s %-s', $1, $5, $4 } += $x;
#       $port{ sprintf 'port %-6s %-s', $1, $4 } += $x;
        $port{ sprintf 'Sig %-6s Severity %-2s', $1, $2 } += $x;
}
my $n;

print "\nSource Address Summary:\n";
foreach my $i ( sort { $srca{$b} <=> $srca{$a} } keys %srca) {
   if ($n++ >= $ntop) { last };
   printf ("%6s: %s\n", $srca{$i},$i);
}
$n=0;

print "Connection Summary:\n";
foreach my $i ( sort { $quad{$b} <=> $quad{$a} } keys %quad) {
   if ($n++ >= $ntop) { last };
   printf ("%6s: %s\n", $quad{$i},$i);
}
$n=0;

print "\nDestination Port Summary:\n";
foreach my $i ( sort { $port{$b} <=> $port{$a} } keys %port) {
   if ($n++ >= $ntop) { last };
   printf ("%6s: %s\n", $port{$i},$i);
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to