summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-09-30 15:50:27 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-09-30 15:50:27 +0000
commit9df818bc1b00b383918f4aa021cfcec4dcc307b9 (patch)
treece2637b838203c0d4ccd72ee8052c1e11e7c1ecc
parent2938739d2e019a7e34b70a9c71ba3903201f6d6d (diff)
downloadperl-9df818bc1b00b383918f4aa021cfcec4dcc307b9.tar.gz
Added Lint option regexp-variables.
p4raw-id: //depot/perlext/Compiler@85
-rw-r--r--B/Lint.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/B/Lint.pm b/B/Lint.pm
index d9659f98a0..df373c2216 100644
--- 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 {