This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #112522] Mildly incorrect wording in "perldoc perlre"
[perl5.git] / pod / perlre.pod
index 8f6a04f..9c5c3ad 100644 (file)
@@ -31,8 +31,8 @@ L<perlop/"Gory details of parsing quoted constructs">.
 X</m> X<regex, multiline> X<regexp, multiline> X<regular expression, multiline>
 
 Treat string as multiple lines.  That is, change "^" and "$" from matching
-the start or end of the string to matching the start or end of any
-line anywhere within the string.
+the start or end of line only at the left and right ends of the string to
+matching them anywhere within the string.
 
 =item s
 X</s> X<regex, single-line> X<regexp, single-line>
@@ -292,7 +292,8 @@ the C<LATIN CAPITAL LETTER SHARP S> will match any of C<SS>, C<Ss>,
 C<sS>, and C<ss>, otherwise not.
 
 This modifier may be specified to be the default by C<use feature
-'unicode_strings> or C<L<use 5.012|perlfunc/use VERSION>> (or higher),
+'unicode_strings>, C<use locale ':not_characters'>, or
+C<L<use 5.012|perlfunc/use VERSION>> (or higher),
 but see L</Which character set modifier is in effect?>.
 X</u>
 
@@ -429,10 +430,13 @@ within its scope.  This pragma has precedence over the other pragmas
 listed below that also change the defaults.
 
 Otherwise, C<L<use locale|perllocale>> sets the default modifier to C</l>;
-and C<L<use feature 'unicode_strings|feature>> or
+and C<L<use feature 'unicode_strings|feature>>, or
 C<L<use 5.012|perlfunc/use VERSION>> (or higher) set the default to
 C</u> when not in the same scope as either C<L<use locale|perllocale>>
-or C<L<use bytes|bytes>>.  Unlike the mechanisms mentioned above, these
+or C<L<use bytes|bytes>>.
+(C<L<use locale ':not_characters'|perllocale/Unicode and UTF-8>> also
+sets the default to C</u>, overriding any plain C<use locale>.)
+Unlike the mechanisms mentioned above, these
 affect operations besides regular expressions pattern matching, and so
 give more consistent results with other operators, including using
 C<\U>, C<\l>, etc. in substitution replacements.
@@ -509,8 +513,23 @@ X<metacharacter> X<quantifier> X<*> X<+> X<?> X<{n}> X<{n,}> X<{n,m}>
 
 (If a curly bracket occurs in any other context and does not form part of
 a backslashed sequence like C<\x{...}>, it is treated
-as a regular character.  In particular, the lower bound
-is not optional.)  The "*" quantifier is equivalent to C<{0,}>, the "+"
+as a regular character.  In particular, the lower quantifier bound
+is not optional.  However, in Perl v5.18, it is planned to issue a
+deprecation warning for all such occurrences, and in Perl v5.20 to
+require literal uses of a curly bracket to be escaped, say by preceding
+them with a backslash or enclosing them within square brackets, (C<"\{">
+or C<"[{]">).  This change will allow for future syntax extensions (like
+making the lower bound of a quantifier optional), and better error
+checking of quantifiers.  Now, a typo in a quantifier silently causes
+it to be treated as the literal characters.  For example,
+
+    /o{4,3}/
+
+looks like a quantifier that matches 0 times, since 4 is greater than 3,
+but it really means to match the sequence of six characters
+S<C<"o { 4 , 3 }">>.)
+
+The "*" quantifier is equivalent to C<{0,}>, the "+"
 quantifier to C<{1,}>, and the "?" quantifier to C<{0,1}>.  n and m are limited
 to non-negative integral values less than a preset limit defined when perl is built.
 This is usually 32766 on the most common platforms.  The actual limit can
@@ -916,6 +935,8 @@ backslash interpolation may lead to confusing results.  If you
 I<need> to use literal backslashes within C<\Q...\E>,
 consult L<perlop/"Gory details of parsing quoted constructs">.
 
+C<quotemeta()> and C<\Q> are fully described in L<perlfunc/quotemeta>.
+
 =head2 Extended Patterns
 
 Perl also defines a consistent extension syntax for features not
@@ -978,7 +999,7 @@ repetition of the previous word, assuming the C</x> modifier, and no C</i>
 modifier outside this group.
 
 These modifiers do not carry over into named subpatterns called in the
-enclosing group. In other words, a pattern such as C<((?i)(&NAME))> does not
+enclosing group. In other words, a pattern such as C<((?i)(?&NAME))> does not
 change the case-sensitivity of the "NAME" pattern.
 
 Any of these modifiers can be set to apply globally to all regular
@@ -1328,8 +1349,9 @@ of evaluation is considered a regular expression and matched as
 if it were inserted instead of this construct.  Note that this means
 that the contents of capture groups defined inside an eval'ed pattern
 are not available outside of the pattern, and vice versa, there is no
-way for the inner pattern to refer to a capture group defined outside.
-Thus,
+way for the inner pattern returned from the code block to refer to a
+capture group defined outside.  (The code block itself can use C<$1>, etc.,
+to refer to the enclosing pattern's capture groups.)  Thus,
 
     ('a' x 100)=~/(??{'(.)' x 100})/