Let's try doing those things manually instead
sub handle_message {
my $message = join "", @{$_[0]};
my $frompat = qr/^From:\s+.*\n # initial line
(?:\s+.*\n)* # continuation lines
/xim;
$count++; $total_size += length $message; letter_histogram( $message ); from_histogram( $message =~ /($frompat)/ ); }
The results:
Before After
real 0m8.356s real 0m1.259s user 0m6.770s user 0m1.230s sys 0m0.030s sys 0m0.020s
Well how about that?
An 81% speedup