FYI, I sent the following to authors of NetAddr::IP module,
and Michael just replied:
> Thanks Mark,
>
> I will incorporate your patch in the next release coming soon.
>
> Best regards,
> Michael
---------- Forwarded Message ----------
Subject: Change in NetAddr-IP-4.010 is polluting apps with sawampersand
Date: Wednesday October 22 2008
From: Mark Martinec <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Luis, Michael,
I just noticed that upgrading NetAddr-IP-4.007 to NetAddr-IP-4.012
causes Mail::SpamAssassin and amavisd-new applications to start
seeing the Perl sawampersand flag being turned on. It took me
a while to track down which Perl module is causing a pollution.
The perlvar man page has the following to say:
$&
The string matched by the last successful pattern match[...]
The use of this variable anywhere in a program imposes a considerable
performance penalty on all regular expression matches. See BUGS.
$`
The string preceding whatever was matched by the last successful [...]
The use of this variable anywhere in a program imposes a considerable
performance penalty on all regular expression matches. See BUGS.
$'
The string following whatever was matched by the last successful [...]
The use of this variable anywhere in a program imposes a considerable
performance penalty on all regular expression matches. See BUGS.
A minimalized sample case, yielding a true for versions NetAddr-IP-4.010
and later, and yielding a false for NetAddr-IP-4.007:
$ perl -e 'use Devel::SawAmpersand; require NetAddr::IP::Lite;
printf("%d\n", Devel::SawAmpersand::sawampersand())'
1
The attached patch (to 4.012) should remove the unnecessary penalty,
and also protects global $n variables from being modified by a
low-end routine.
I should add that Mail::SpamAssassin team went into considerable
effort in the past to root out the potential and unnecessary
performance penalty from some underlying library modules.
It is possible that recent version of Perl has minimized the
performance hit, but lots of folks are still running 'stable'
versions of Perl, so it would be nice to root out the sawampersand.
Best regards
Mark
-- Lite/Util/Util.pm~ 2008-10-17 04:36:05.000000000 +0200
+++ Lite/Util/Util.pm 2008-10-22 20:41:57.000000000 +0200
@@ -281,7 +281,8 @@
my($ipv6) = @_;
return undef unless $ipv6;
- if ($ipv6 =~ /:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) { # mixed
hex, dot-quad
- return undef if $1 > 255 || $2 > 255 || $3 > 255 || $4 > 255;
- $ipv6 = sprintf("%s:%X%02X:%X%02X",$`,$1,$2,$3,$4);
# convert to pure hex
+ local($1,$2,$3,$4,$5);
+ if ($ipv6 =~ /^(.*:)(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) { # mixed
hex, dot-quad
+ return undef if $2 > 255 || $3 > 255 || $4 > 255 || $5 > 255;
+ $ipv6 = sprintf("%s:%X%02X:%X%02X",$1,$2,$3,$4,$5);
# convert to pure hex
}
my $c;
-------------------------------------------------------