diff options
author | Bram <perl-rt@wizbit.be> | 2008-07-24 20:14:27 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-08-24 14:52:12 +0000 |
commit | 777723442a58c6c86c224d8d746a30441a5bdfbd (patch) | |
tree | 45abacfc91df8bbbad01c3db7771db22c96333e9 /toke.c | |
parent | 228ee848f02d1db8db39c97ee13c0c9975afa083 (diff) | |
download | perl-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.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 */ |