summaryrefslogtreecommitdiff
path: root/pod/perlretut.pod
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-25 14:50:48 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-27 07:05:04 -0800
commitd78f32f607952d58a998c5b7554572320dc57b2a (patch)
tree73fac57f0e79e1b542357b4935cf4480ba397748 /pod/perlretut.pod
parent20961b6483f3653e3bf928a60cca828e2b13e098 (diff)
downloadperl-d78f32f607952d58a998c5b7554572320dc57b2a.tar.gz
Update docs to concur with $`,$&,$' changes
plus a couple of other pod tweaks.
Diffstat (limited to 'pod/perlretut.pod')
-rw-r--r--pod/perlretut.pod12
1 files changed, 9 insertions, 3 deletions
diff --git a/pod/perlretut.pod b/pod/perlretut.pod
index bf4ab3bc29..11ad1f64a3 100644
--- a/pod/perlretut.pod
+++ b/pod/perlretut.pod
@@ -900,7 +900,10 @@ of the string after the match. An example:
In the second match, C<$`> equals C<''> because the regexp matched at the
first character position in the string and stopped; it never saw the
-second 'the'. It is important to note that using C<$`> and C<$'>
+second 'the'.
+
+If your code is to run on Perl versions earlier than
+5.18, it is worthwhile to note that using C<$`> and C<$'>
slows down regexp matching quite a bit, while C<$&> slows it down to a
lesser extent, because if they are used in one regexp in a program,
they are generated for I<all> regexps in the program. So if raw
@@ -913,8 +916,11 @@ C<@+> instead:
$' is the same as substr( $x, $+[0] )
As of Perl 5.10, the C<${^PREMATCH}>, C<${^MATCH}> and C<${^POSTMATCH}>
-variables may be used. These are only set if the C</p> modifier is present.
-Consequently they do not penalize the rest of the program.
+variables may be used. These are only set if the C</p> modifier is
+present. Consequently they do not penalize the rest of the program. In
+Perl 5.18, C<${^PREMATCH}>, C<${^MATCH}> and C<${^POSTMATCH}> are available
+whether the C</p> has been used or not (the modifier is ignored), and
+C<$`>, C<$'> and C<$&> do not cause any speed difference.
=head2 Non-capturing groupings