diff options
author | Karl Williamson <khw@khw-desktop.(none)> | 2010-06-22 14:29:10 -0600 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2010-06-28 22:30:04 -0400 |
commit | d8b950dcbc51bd501c5dc196cc12d87eaf47b60c (patch) | |
tree | fd00ef847f27621f035f8c4fd827df582fa1433d /pod/perlfaq4.pod | |
parent | c27a5cfe2661343fcb3b4f58478604d8b59b20de (diff) | |
download | perl-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/perlfaq4.pod')
-rw-r--r-- | pod/perlfaq4.pod | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index 45cc9e044d..2e35068c31 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -594,11 +594,11 @@ This won't expand C<"\n"> or C<"\t"> or any other special escapes. You can use the substitution operator to find pairs of characters (or runs of characters) and replace them with a single instance. In this substitution, we find a character in C<(.)>. The memory parentheses -store the matched character in the back-reference C<\1> and we use +store the matched character in the back-reference C<\g1> and we use that to require that the same thing immediately follow it. We replace that part of the string with the character in C<$1>. - s/(.)\1/$1/g; + s/(.)\g1/$1/g; We can also use the transliteration operator, C<tr///>. In this example, the search list side of our C<tr///> contains nothing, but @@ -1162,7 +1162,7 @@ subsequent line. sub fix { local $_ = shift; my ($white, $leader); # common whitespace and common leading string - if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) { + if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\g1\g2?.*\n)+$/) { ($white, $leader) = ($2, quotemeta($1)); } else { ($white, $leader) = (/^(\s+)/, ''); |