#!/usr/bin/perl -w use strict; my %fol_count; my %fol_bytes; my $spam_count; my $spam_bytes; my $ham_count; my $ham_bytes; my $width = 0; while (<>) { if (/^ Folder: ([\/A-Za-z0-9_.-]+?)(?:\/new\/\d+.\d+_\d+.\w+)?\s+(\d+)$/) { my $folder = $1; my $msg_bytes = $2; $width = length $folder if length $folder > $width; if ($1 =~ /spam/ || $1 eq "/dev/null" || $1 eq "killed/garbage") { $spam_count++; $spam_bytes += $msg_bytes; } else { $ham_count++; $ham_bytes += $msg_bytes; } $fol_count{$folder}++; $fol_bytes{$folder} += $msg_bytes; } } for (sort {$fol_count{$b} <=> $fol_count{$a}} keys %fol_count) { print_fol($_, $fol_count{$_}, $fol_bytes{$_}/1024); } print "\n"; print_fol("HAM TOTAL", $ham_count, $ham_bytes/1024); print_fol("SPAM TOTAL", $spam_count, $spam_bytes/1024); sub print_fol { my ($name, $count, $kb) = @_; my $w = $width+1; printf "%-${w}.${w}s %4d msgs %8.2f kb\n", "$name:", $count, $kb; }