#!/usr/bin/perl -w

use strict;
my %stat = ();
my $counter = 0;

while (<>) {
	chomp;
	next if $_ eq '';
	s/\s*(?:\(|<).+@.+\..+(?:\)|>)\s*//;
	exists $stat{ $_ } ? $stat{ $_ } += 1 : ($stat{ $_ } = 1);
	$counter += 1;
}

my $maxlen = 0;
my $strmaxlen = 0;
map { $maxlen = length($stat{ $_ }) if length($stat{ $_ }) > $maxlen } keys %stat;
map { $strmaxlen = length($_) if length($_) > $strmaxlen } keys %stat;
$maxlen = length($counter) if $maxlen < length($counter);
print "-", "-" x $maxlen, "+--------+-", "-" x $strmaxlen, "-\n";
print sprintf(" %${maxlen}d| %6.2f%%| %s ", $counter, 100, "TOTAL"),"\n";
print "-", "-" x $maxlen, "+--------+-", "-" x $strmaxlen, "-\n";
foreach my $key (sort { $stat{ $b } <=> $stat{ $a } } keys %stat) {
	print sprintf(" %${maxlen}d| %6.2f%%| %s ", $stat{ $key }, ($stat{ $key } / $counter * 100), $key),"\n";
}
print "-", "-" x $maxlen, "+--------+-", "-" x $strmaxlen, "-\n";
