diff options
author | Yves Orton <demerphq@gmail.com> | 2016-11-02 10:53:18 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2016-11-02 10:57:12 +0100 |
commit | 6d31468305788870c92226c07d8edd65deb96ea5 (patch) | |
tree | 08747e195977b4e54a93712e3a8e75757f935b18 /pod | |
parent | 26e9d721e16d30fc642c2452ef40e778a6302f3f (diff) | |
download | perl-6d31468305788870c92226c07d8edd65deb96ea5.tar.gz |
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.
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perlop.pod | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index d65e911a1e..75f266c657 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>. |