diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-09-30 15:50:27 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-09-30 15:50:27 +0000 |
commit | 9df818bc1b00b383918f4aa021cfcec4dcc307b9 (patch) | |
tree | ce2637b838203c0d4ccd72ee8052c1e11e7c1ecc | |
parent | 2938739d2e019a7e34b70a9c71ba3903201f6d6d (diff) | |
download | perl-9df818bc1b00b383918f4aa021cfcec4dcc307b9.tar.gz |
Added Lint option regexp-variables.
p4raw-id: //depot/perlext/Compiler@85
-rw-r--r-- | B/Lint.pm | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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 { |