From d8b950dcbc51bd501c5dc196cc12d87eaf47b60c Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 22 Jun 2010 14:29:10 -0600 Subject: 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. --- pod/perlfaq4.pod | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pod/perlfaq4.pod') 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. In this example, the search list side of our C 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+)/, ''); -- cgit v1.2.1