From: Malcolm Beattie Date: Tue, 30 Sep 1997 15:50:27 +0000 (+0000) Subject: Added Lint option regexp-variables. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9df818bc1b00b383918f4aa021cfcec4dcc307b9;p=p5sagit%2Fp5-mst-13.2.git Added Lint option regexp-variables. p4raw-id: //depot/perlext/Compiler@85 --- diff --git a/B/Lint.pm b/B/Lint.pm index d9659f9..df373c2 100644 --- a/B/Lint.pm +++ b/B/Lint.pm @@ -76,6 +76,13 @@ or C<$obj-Emeth()>. Note that some programs or modules delay definition of subs until runtime by means of the AUTOLOAD mechanism. +=item B + +This option warns whenever one of the regexp variables $', $& or +$' is used. Any occurrence of any of these variables in your +program can slow your whole program down. See L for +details. + =item B Turn all warnings on. @@ -138,7 +145,7 @@ my %valid_check; BEGIN { map($valid_check{$_}++, qw(context implicit_read implicit_write dollar_underscore - private_names undefined_subs)); + private_names undefined_subs regexp_variables)); } # Debugging options @@ -259,6 +266,12 @@ sub B::GVOP::lint { } } } + if ($check{regexp_variables} && $op->ppaddr eq "pp_gvsv") { + my $name = $op->gv->NAME; + if ($name =~ /^[&'`]$/) { + warning('Use of regexp variable $%s', $name); + } + } } sub B::GV::lintcv {