New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\c\@ and \c\\@ weirdness in patterns #14331
Comments
From @cpansproutLet’s look at qq strings first: In the first case, the \c swallows up the \ and the @a that follows interpolates: $ ./perl -Ilib -le 'use Devel::Peek; @a = "a"; Dump "\c\@a"' In the second case, \c\ again is treated as a unit and \@a is a literal '@a' because the @ is escaped: $ ./perl -Ilib -le 'use Devel::Peek; @a = "a"; Dump "\c\\@a"' But it behaves differently when it comes to patterns: $ ./perl -Ilib -Mre=debug -le '@a = "a"; /\c\@a/' There the backslash after the \c is \c’s character and *also* escapes the @. It is doing two things at once. With a double backslash, it is just bizarre: $ ./perl -Ilib -Mre=debug -le '@a = "a"; /\c\\@a/' Here it appears that the double backslash allows interpolation of @a, resulting in \c\\a, which then compiles to \c\ (\34) followed by \a (\7). So I managed to create an escape sequence with a literal backslash and an interpolated variable. That is quite something. I think the regexp cases should behave very similarly to the qq cases. I think the fix for this is for the lexer to treat \c\ exactly the way it does \\: treat it as one unit and skip over it. That would also affect "\c\\" (currently equivalent to "\34\\", believe it or not; it would be a syntax error; "\c\" would give "\34" and "\c\\\" would give "\34\\"), and possibly break about 3 CPAN modules. -- Father Chrysostomos |
From @demerphqOn 13 December 2014 at 05:36, Father Chrysostomos <perlbug-followup@perl.org
This all makes sense to me. cheers, -- |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#123423 (status was 'open')
Searchable as RT123423$
The text was updated successfully, but these errors were encountered: