X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/563642b4907d9b1b6beaa96b472ae787ae81d56f..fb5f378b17e3b41db03064c19b9205db64a3354c:/pod/perlretut.pod
diff --git a/pod/perlretut.pod b/pod/perlretut.pod
index d72d52d..1e1cdd4 100644
--- a/pod/perlretut.pod
+++ b/pod/perlretut.pod
@@ -23,30 +23,30 @@ characteristics. The string is most often some text, such as a line,
sentence, web page, or even a whole book, but less commonly it could be
some binary data as well.
Suppose we want to determine if the text in variable, C<$var> contains
-the sequence of characters C C is
in effect, as explained below).
=item *
-\N, like the period, matches any character but "\n", but it does so
-regardless of whether the modifier C/s> is in effect.
+C<\N>, like the period, matches any character but C<"\n">, but it does so
+regardless of whether the modifier C is in effect.
=back
-The C/a> modifier, available starting in Perl 5.14, is used to
-restrict the matches of \d, \s, and \w to just those in the ASCII range.
+The C modifier, available starting in Perl 5.14, is used to
+restrict the matches of C<\d>, C<\s>, and C<\w> to just those in the ASCII range.
It is useful to keep your program from being needlessly exposed to full
Unicode (and its accompanying security considerations) when all you want
-is to process English-like text. (The "a" may be doubled, C/aa>, to
+is to process English-like text. (The "a" may be doubled, C, to
provide even more restrictions, preventing case-insensitive matching of
ASCII with non-ASCII characters; otherwise a Unicode "Kelvin Sign"
would caselessly match a "k" or "K".)
@@ -502,48 +517,48 @@ of it as empty. Then
This behavior is convenient, because we usually want to ignore
newlines when we count and match characters in a line. Sometimes,
-however, we want to keep track of newlines. We might even want C<^>
-and C<$> to anchor at the beginning and end of lines within the
+however, we want to keep track of newlines. We might even want C<'^'>
+and C<'$'> to anchor at the beginning and end of lines within the
string, rather than just the beginning and end of the string. Perl
allows us to choose between ignoring and paying attention to newlines
-by using the C/s> and C/m> modifiers. C/s> and C/m> stand for
+by using the C and C
expressions turn that around by allowing
arbitrary Perl code to be a part of a regexp. A code evaluation
-expression is denoted C<(?{code})>, with I a string of Perl
+expression is denoted C<(?{I})>, with I a string of Perl
statements.
-Be warned that this feature is considered experimental, and may be
-changed without notice.
-
Code expressions are zero-width assertions, and the value they return
depends on their environment. There are two possibilities: either the
code expression is used as a conditional in a conditional expression
-C<(?(condition)...)>, or it is not. If the code expression is a
-conditional, the code is evaluated and the result (i.e., the result of
+C<(?(I)...)>, or it is not. If the code expression is a
+conditional, the code is evaluated and the result (I, the result of
the last statement) is used to determine truth or falsehood. If the
code expression is not used as a conditional, the assertion always
evaluates true and the result is put into the special variable
@@ -2558,12 +2597,12 @@ example:
Hmm. What happened here? If you've been following along, you know that
the above pattern should be effectively (almost) the same as the last one;
-enclosing the C in a character class isn't going to change what it
+enclosing the C<'d'> in a character class isn't going to change what it
matches. So why does the first not print while the second one does?
-The answer lies in the optimizations the regex engine makes. In the first
+The answer lies in the optimizations the regexp engine makes. In the first
case, all the engine sees are plain old characters (aside from the
-C{}> construct). It's smart enough to realize that the string 'ddd'
+C{}> construct). It's smart enough to realize that the string C<'ddd'>
doesn't occur in our target string before actually running the pattern
through. But in the second case, we've tricked it into thinking that our
pattern is more complicated. It takes a look, sees our
@@ -2589,7 +2628,7 @@ backtracks in the process of searching for a match. If the regexp
backtracks over a code expression and if the variables used within are
localized using C, the changes in the variables produced by the
code expression are undone! Thus, if we wanted to count how many times
-a character got matched inside a group, we could use, e.g.,
+a character got matched inside a group, we could use, I,
$x = "aaaa";
$count = 0; # initialize 'a' count
@@ -2630,7 +2669,8 @@ The result C<$^R> is automatically localized, so that it will behave
properly in the presence of backtracking.
This example uses a code expression in a conditional to match a
-definite article, either 'the' in English or 'der|die|das' in German:
+definite article, either C<'the'> in English or C<'der|die|das'> in
+German:
$lang = 'DE'; # use German
...
@@ -2644,8 +2684,8 @@ definite article, either 'the' in English or 'der|die|das' in German:
)
/xi;
-Note that the syntax here is C<(?(?{...})yes-regexp|no-regexp)>, not
-C<(?((?{...}))yes-regexp|no-regexp)>. In other words, in the case of a
+Note that the syntax here is C<(?(?{...})I|I)>, not
+C<(?((?{...}))I|I)>. In other words, in the case of a
code expression, we don't need the extra parentheses around the
conditional.
@@ -2703,7 +2743,7 @@ expression and matched immediately. A simple example is
This final example contains both ordinary and pattern code
expressions. It detects whether a binary string C<1101010010001...> has a
-Fibonacci spacing 0,1,1,2,3,5,... of the C<1>'s:
+Fibonacci spacing 0,1,1,2,3,5,... of the C<'1'>'s:
$x = "1101010010001000001";
$z0 = ''; $z1 = '0'; # initial conditions
@@ -2732,7 +2772,7 @@ expression. Rather, the whole code block is parsed as perl code at the
same time as perl is compiling the code containing the literal regexp
pattern.
-The regexp without the C/x> modifier is
+This regexp without the C modifier is
/^1(?:((??{ $z0 }))1(?{ $z0 = $z1; $z1 .= $^N; }))+$/
@@ -2745,11 +2785,9 @@ regexps is almost necessary in creating and debugging regexps.
Perl 5.10 introduced a number of control verbs intended to provide
detailed control over the backtracking process, by directly influencing
-the regexp engine and by providing monitoring techniques. As all
-the features in this group are experimental and subject to change or
-removal in a future version of Perl, the interested reader is
-referred to L for a
-detailed description.
+the regexp engine and by providing monitoring techniques. See
+L for a detailed
+description.
Below is just one example, illustrating the control verb C<(*FAIL)>,
which may be abbreviated as C<(*F)>. If this is inserted in a regexp
@@ -2863,7 +2901,7 @@ part
describes the compilation stage. C means that there is a
starred object, in this case C<'a'>, and if it matches, goto line 4,
-i.e., C. The middle lines describe some heuristics and
+I, C. The middle lines describe some heuristics and
optimizations performed before a match:
floating 'bc' at 0..2147483647 (checking floating) minlen 2
@@ -2921,11 +2959,6 @@ prints
t2
Done at position 4
-=head1 BUGS
-
-Code expressions, conditional expressions, and independent expressions
-are I. Don't use them in production code. Yet.
-
=head1 SEE ALSO
This is just a tutorial. For the full story on Perl regular
@@ -2941,8 +2974,9 @@ Jeffrey Friedl (published by O'Reilly, ISBN 1556592-257-3).
=head1 AUTHOR AND COPYRIGHT
-Copyright (c) 2000 Mark Kvale
+Copyright (c) 2000 Mark Kvale.
All rights reserved.
+Now maintained by Perl porters.
This document may be distributed under the same terms as Perl itself.