summaryrefslogtreecommitdiff
path: root/pod/perlrequick.pod
diff options
context:
space:
mode:
authorKarl Williamson <khw@khw-desktop.(none)>2010-06-22 14:29:10 -0600
committerJesse Vincent <jesse@bestpractical.com>2010-06-28 22:30:04 -0400
commitd8b950dcbc51bd501c5dc196cc12d87eaf47b60c (patch)
treefd00ef847f27621f035f8c4fd827df582fa1433d /pod/perlrequick.pod
parentc27a5cfe2661343fcb3b4f58478604d8b59b20de (diff)
downloadperl-d8b950dcbc51bd501c5dc196cc12d87eaf47b60c.tar.gz
Prefer \g1 over \1 in pods
\g was added to avoid ambiguities that \digit causes. This updates the pod documentation to use \g in examples, and to prefer it when explaining the concepts. Some non-symmetrical outlined text dealing with it was also cleaned up.
Diffstat (limited to 'pod/perlrequick.pod')
-rw-r--r--pod/perlrequick.pod10
1 files changed, 5 insertions, 5 deletions
diff --git a/pod/perlrequick.pod b/pod/perlrequick.pod
index ded1e6cefc..1fde5588d6 100644
--- a/pod/perlrequick.pod
+++ b/pod/perlrequick.pod
@@ -298,13 +298,13 @@ indicated below it:
1 2 34
Associated with the matching variables C<$1>, C<$2>, ... are
-the B<backreferences> C<\1>, C<\2>, ... Backreferences are
+the B<backreferences> C<\g1>, C<\g2>, ... Backreferences are
matching variables that can be used I<inside> a regex:
- /(\w\w\w)\s\1/; # find sequences like 'the the' in string
+ /(\w\w\w)\s\g1/; # find sequences like 'the the' in string
-C<$1>, C<$2>, ... should only be used outside of a regex, and C<\1>,
-C<\2>, ... only inside a regex.
+C<$1>, C<$2>, ... should only be used outside of a regex, and C<\g1>,
+C<\g2>, ... only inside a regex.
=head2 Matching repetitions
@@ -347,7 +347,7 @@ Here are some examples:
/[a-z]+\s+\d*/; # match a lowercase word, at least some space, and
# any number of digits
- /(\w+)\s+\1/; # match doubled words of arbitrary length
+ /(\w+)\s+\g1/; # match doubled words of arbitrary length
$year =~ /\d{2,4}/; # make sure year is at least 2 but not more
# than 4 digits
$year =~ /\d{4}|\d{2}/; # better match; throw out 3 digit dates