Yes, this declared a hash to store the results of counting the lines. The key will be one of either 'CLEAN','SPAM','INFECTED','BANNED','BAD_HEADER','REJECTED' and the value is the count.
while (<$fh>){Read each line of the file into $_
if (/amavis.*(Passed|Blocked) (CLEAN|SPAM|INFECTED|BANNED)/){Match the line read (in $_) against the regex pattern like grep. The first word captured (Passed or Block) will be in $1 and the second (CLEAN or SPAM or INFECTED or BANNED) will be in $2
++$count{$2}; # Why ++$count? why {$2} here? is it bcos of (Passed +|Blocked) ?
For example, if $2 is the word CLEAN increment the hash $count{'CLEAN'}
} elsif (/amavis.*(BAD-HEADER)-/) { ++$count{$1}; # why {$1} here? is it bcos of (BAD-HEADER)
Yes, this regex has only 1 set of brackets so if it matches the word BAD-HEADER will be in $1
} elsif (/reject/){ ++$count{'REJECTED'}; #Hmm, Why {'REJECTED'}? } }
I chose REJECTED because 'rejected' was the label in your graph and all the other keys are upper case
my @data = map{ $count{$_} || 0 } qw(CLEAN SPAM INFECTED BANNED BAD-HEADER REJECTED);map is a convenient way of creating an array from another another array. It is the same as
pojmy @data=(); $data[0] = $count{'CLEAN'} || 0; # use 0 if $count{'CLEAN'} is undefin +ed $data[1] = $count{'SPAM'} || 0; $data[2] = $count{'INFECTED'} || 0; $data[3] = $count{'BANNED'} || 0; $data[4] = $count{'BAD-HEADER'} || 0; $data[5] = $count{'REJECTED'} || 0;
In reply to Re^7: problem with show_values => 1, while drawing a bar graph with variables
by poj
in thread problem with show_values => 1, while drawing a bar graph with variables
by theravadamonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |