# Define our buckets for collecting data my %bucket = (); my %USER = (); my %VIRUS = (); my %SPAM = ();
my creates a variable in an empty state. Assigning emptiness to an empty container is redundant.
# These numbers must be valid reason codes... my @wanted = ( 1, 60 );
It would be more efficient to use a hash instead of an array there.
for (<$file>)
A for loop iterates over a list which means that the entire contents of the file have to be stored in a list in memory before it can be iterated over. It is more efficient to use a while loop which only reads one line at a time.
while ( <$file> )
chomp; my ( $month, $day, $time, $host, $process, $clientIP, $MessageID, $timeStart, $timeEnd, $service, @INFO ) = split /\s+/;
The chomp is superfluous because split /\s+/ removes all whitespace. You are declaring eleven variables but you are only using three. You can use undef as a placeholder:
my ( undef, undef, undef, $host, undef, undef, undef, undef, undef, $s +ervice, @INFO ) = split;
$USER{$host}{$recip}{$action{$service}{$action_}}{$reason{$rea +son_}}{'count'}++; #if ( grep /^$reason_$/, @wanted );
If you had used a hash for wanted then you would not need to use grep.
$USER{$host}{$recip}{$action{$service}{$action_}}{$reason{$rea +son_}}{'count'}++; #if exists $wanted{ $reason_ };

In reply to Re: spamstats.pl by jwkrahn
in thread spamstats.pl by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.