#!/usr/bin/perl use strict ; use constant DEBUG => 0 ; my %counter ; { my %slots ; my @delivered ; open LOG,"< mail.log.filtered" or die $! ; while () { chomp ; my $id ; if (/(from|to)=<(\S+)>/) { my $direct = $1 ; my $actor = $2 ; $id = (split)[5] ; $id =~ s/:$// ; $slots{$id}{$direct} = $actor ; } if (defined $id and exists $slots{$id}{from} and exists $slots{$id}{to} ) { my ($from,$to) = @{$slots{$id}}{qw(from to)} ; print STDERR "DEBUG: [$from]->[$to]\n" if DEBUG ; push @delivered,[$id,$from,$to] if $to =~ /^cxpanico/ ; delete $slots{$id} ; } } close LOG or warn $! ; foreach my $ref (@delivered) { my ($id,$from,$to) = @$ref ; $counter{$from}++ ; } } foreach my $sender (reverse sort { $counter{$a} <=> $counter{$b} } keys %counter ) { print "$sender: $counter{$sender} mail" ; print "s" if $counter{$sender} > 1 ; print "\n" ; }