This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Added Lint option regexp-variables.
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Tue, 30 Sep 1997 15:50:27 +0000 (15:50 +0000)
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Tue, 30 Sep 1997 15:50:27 +0000 (15:50 +0000)
p4raw-id: //depot/perlext/Compiler@85

B/Lint.pm

index d9659f9..df373c2 100644 (file)
--- a/B/Lint.pm
+++ b/B/Lint.pm
@@ -76,6 +76,13 @@ or C<$obj-E<gt>meth()>. Note that some programs or modules delay
 definition of subs until runtime by means of the AUTOLOAD
 mechanism.
 
+=item B<regexp-variables>
+
+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<perlre> for
+details.
+
 =item B<all>
 
 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 {