Next Making Programs Faster 45

handle_message

        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)/ );
        }
        Before                  After
        real    0m8.356s        real    0m1.259s
        user    0m6.770s        user    0m1.230s
        sys     0m0.030s        sys     0m0.020s

Next Copyright © 2003 M. J. Dominus