Skip Menu |

This queue is for tickets about the Mail-Box CPAN distribution.

Report information
The Basics
Id: 11756
Status: resolved
Priority: 0/
Queue: Mail-Box

People
Owner: Nobody in particular
Requestors: jgmyers [...] proofpoint.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Use of $& slows down all regexes
Mail::Box has references to $&. Any reference to $& slows down the execution of every regex encountered by the Perl interpreter. The attached patch recodes these references so that they don't trigger this performance penalty.
diff -ur Mail-Box-2.059-orig/lib/Mail/Message/Head/Complete.pm Mail-Box-2.059/lib/Mail/Message/Head/Complete.pm --- Mail-Box-2.059-orig/lib/Mail/Message/Head/Complete.pm 2004-11-30 10:53:17.000000000 -0800 +++ Mail-Box-2.059/lib/Mail/Message/Head/Complete.pm 2005-03-04 10:00:37.000000000 -0800 @@ -511,7 +511,7 @@ my $from = $self->get('from') || ''; my $stamp = $self->timestamp; - my $sender = $from =~ m/\<.*?\>/ ? $& : 'unknown'; + my $sender = $from =~ m/(\<.*?\>)/ ? $1 : 'unknown'; "From $sender ".(gmtime $stamp)."\n"; } Only in Mail-Box-2.059/lib/Mail/Message/Head: Complete.pm~ diff -ur Mail-Box-2.059-orig/lib/Mail/Message/TransferEnc/SevenBit.pm Mail-Box-2.059/lib/Mail/Message/TransferEnc/SevenBit.pm --- Mail-Box-2.059-orig/lib/Mail/Message/TransferEnc/SevenBit.pm 2004-11-30 10:53:18.000000000 -0800 +++ Mail-Box-2.059/lib/Mail/Message/TransferEnc/SevenBit.pm 2005-03-04 10:01:07.000000000 -0800 @@ -34,7 +34,7 @@ my $changes = 0; foreach ($body->lines) - { $changes++ if s/[^\000-\127]/chr(ord($&) & 0x7f)/ge; + { $changes++ if s/([^\000-\127])/chr(ord($1) & 0x7f)/ge; $changes++ if s/[\000\013]//g; $changes++ if length > 997; Only in Mail-Box-2.059/lib/Mail/Message/TransferEnc: SevenBit.pm~
AFAIK, the most recent perl releases have removed the penalty, but your patch is applied anyway. Thanks for the report.