In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/6d31468305788870c92226c07d8edd65deb96ea5?hp=26e9d721e16d30fc642c2452ef40e778a6302f3f>
- Log ----------------------------------------------------------------- commit 6d31468305788870c92226c07d8edd65deb96ea5 Author: Yves Orton <demer...@gmail.com> Date: Wed Nov 2 10:53:18 2016 +0100 clarify behavior single quote regexps The documentation was ambiguous about what type of interpolation was disabled in single quote regexps. It is a bit debateable whether "\n" in a regex is a regexp meta-escapes which happens to match "\n", or if it is a string escape that needs to be interpolated. Since single quote regexps should allow regexp meta-escapes (for instance \s), then it makes more sense to treat \n and \x{..} also as regexp meta-escapes, which then leaves nothing but variables that /could/ be interpolated. This effectively officially defines the current behavior as correct, and will allow us to close a number of tickets because of it. In particular we can close #21491 as "not a bug", and probably also related tickets. ----------------------------------------------------------------------- Summary of changes: pod/perlop.pod | 12 ++++++------ t/re/pat.t | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pod/perlop.pod b/pod/perlop.pod index d65e911..75f266c 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -1676,8 +1676,8 @@ X<qr> X</i> X</m> X</o> X</s> X</x> X</p> This operator quotes (and possibly compiles) its I<STRING> as a regular expression. I<STRING> is interpolated the same way as I<PATTERN> -in C<m/I<PATTERN>/>. If C<"'"> is used as the delimiter, no interpolation -is done. Returns a Perl value which may be used instead of the +in C<m/I<PATTERN>/>. If C<"'"> is used as the delimiter, no variable +interpolation is done. Returns a Perl value which may be used instead of the corresponding C</I<STRING>/msixpodualn> expression. The returned value is a normalized version of the original pattern. It magically differs from a string containing the same characters: C<ref(qr/x/)> returns "Regexp"; @@ -1786,7 +1786,7 @@ as delimiters. This is particularly useful for matching path names that contain C<"/">, to avoid LTS (leaning toothpick syndrome). If C<"?"> is the delimiter, then a match-only-once rule applies, described in C<m?I<PATTERN>?> below. If C<"'"> (single quote) is the delimiter, -no interpolation is performed on the I<PATTERN>. +no variable interpolation is performed on the I<PATTERN>. When using a delimiter character valid in an identifier, whitespace is required after the C<m>. @@ -2070,7 +2070,7 @@ the string specified must be a scalar variable, an array element, a hash element, or an assignment to one of those; that is, some sort of scalar lvalue. -If the delimiter chosen is a single quote, no interpolation is +If the delimiter chosen is a single quote, no variable interpolation is done on either the I<PATTERN> or the I<REPLACEMENT>. Otherwise, if the I<PATTERN> contains a C<$> that looks like a variable rather than an end-of-string test, the variable will be interpolated into the pattern @@ -2382,8 +2382,8 @@ must have its own pair of quotes, which may or may not be bracketing quotes; for example, C<tr[aeiouy][yuoiea]> or C<tr(+\-*/)/ABCD/>. Characters may be literals or any of the escape sequences accepted in -double-quoted strings. But there is no interpolation, so C<"$"> and -C<"@"> are treated as literals. A hyphen at the beginning or end, or +double-quoted strings. But there is no variable interpolation, so C<"$"> +and C<"@"> are treated as literals. A hyphen at the beginning or end, or preceded by a backslash is considered a literal. Escape sequence details are in L<the table near the beginning of this section|/Quote and Quote-like Operators>. diff --git a/t/re/pat.t b/t/re/pat.t index 5e863fa..eb321e9 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -1819,9 +1819,8 @@ EOP like("sS", qr/\N{}Ss|/i, "\N{} with empty branch alternation works"); } - TODO: { - local $::TODO = "RT #21491: m'' interpolates escape sequences"; - is(0+("\n" =~ m'\n'), 0, q|RT #21491: m'\n' should not interpolate|); + { + is(0+("\n" =~ m'\n'), 1, q|m'\n' should interpolate escapes|); } { -- Perl5 Master Repository