tall_man has asked for the wisdom of the Perl Monks concerning the following question:
Only the last method on that page works for perl 5.8.0. The "-Mre=debug" does not show either 'Enabling $`, $&, $' support' or 'Omitting $`, $&, $' support' any more.
The Devel::SawAmpersand doesn't work either. It gives false positives on trivial programs that don't have the "naughty match variables".
Here is the subroutine that actually worked:
use strict; use Time::HiRes; sub CheckNaughtiness () { my $text = 'x' x 10_000; my $start = Time::HiRes::time(); for (my $i = 0; $i < 5_000; $i++) { } my $overhead = Time::HiRes::time() - $start; $start = Time::HiRes::time(); for (my $i = 0; $i < 5_000; $i++) { $text =~ m/^/} my $delta = Time::HiRes::time() - $start; printf "It seems your code is %s (overhead=%.2f, delta=%.2f)\n", ($delta > $overhead*5) ? "naughty" : "clean", $overhead, $delta; }
It makes me wonder how many other CPAN modules are tainted with "naughty match variables". Another way to get tainted is to do:
Has anyone else noticed this problem? Should there be a general check for "naughty match variables" for code submitted to CPAN?# Don't do this: use English; # Do this instead: use English qw( -no_match_vars );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Naughty match variables in CPAN?
by Dog and Pony (Priest) on Jul 22, 2003 at 02:30 UTC | |
by sauoq (Abbot) on Jul 22, 2003 at 02:41 UTC | |
by Dog and Pony (Priest) on Jul 22, 2003 at 02:55 UTC | |
by diotalevi (Canon) on Jul 22, 2003 at 05:44 UTC | |
by jsprat (Curate) on Jul 22, 2003 at 09:39 UTC | |
|
Re: Naughty match variables in CPAN?
by waswas-fng (Curate) on Jul 22, 2003 at 04:34 UTC | |
by theorbtwo (Prior) on Jul 22, 2003 at 06:25 UTC | |
|
Re: Naughty match variables in CPAN?
by TomDLux (Vicar) on Jul 22, 2003 at 07:46 UTC | |
|
Re: Naughty match variables in CPAN?
by zakzebrowski (Curate) on Jul 22, 2003 at 12:20 UTC |