summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorBram <perl-rt@wizbit.be>2008-07-24 20:14:27 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-08-24 14:52:12 +0000
commit777723442a58c6c86c224d8d746a30441a5bdfbd (patch)
tree45abacfc91df8bbbad01c3db7771db22c96333e9 /toke.c
parent228ee848f02d1db8db39c97ee13c0c9975afa083 (diff)
downloadperl-777723442a58c6c86c224d8d746a30441a5bdfbd.tar.gz
Unintented interpolation of $/ in regex (was: Re: [perl
Message-ID: <20080724181427.aiml4sdvr40k4coc@horde.wizbit.be> Note that the Subject: has a typo - it should be $\ This adds a new warning. I moved the tests from the original patch to t/lib/warnings/toke. p4raw-id: //depot/perl@34224
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index e98e47c4c7..b2ba362565 100644
--- a/toke.c
+++ b/toke.c
@@ -2173,8 +2173,13 @@ S_scan_const(pTHX_ char *start)
else if (*s == '$') {
if (!PL_lex_inpat) /* not a regexp, so $ must be var */
break;
- if (s + 1 < send && !strchr("()| \r\n\t", s[1]))
+ if (s + 1 < send && !strchr("()| \r\n\t", s[1])) {
+ if (s[1] == '\\' && ckWARN(WARN_AMBIGUOUS)) {
+ Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
+ "Possible unintended interpolation of $\\ in regex");
+ }
break; /* in regexp, $ might be tail anchor */
+ }
}
/* End of else if chain - OP_TRANS rejoin rest */