summaryrefslogtreecommitdiff
path: root/pod/perlrebackslash.pod
diff options
context:
space:
mode:
authorKarl Williamson <khw@khw-desktop.(none)>2010-06-22 15:01:01 -0600
committerJesse Vincent <jesse@bestpractical.com>2010-06-28 22:30:05 -0400
commitce7b6f06f41c076280ab53e616c11c68b71e5ef7 (patch)
tree992f1bbdfd40e0fae030828f52c745968561b426 /pod/perlrebackslash.pod
parent301ba1afeb2ee79c2a7681e2b9dcb8f9231673f7 (diff)
downloadperl-ce7b6f06f41c076280ab53e616c11c68b71e5ef7.tar.gz
Prefer 3 digit octal character constants
By example and a few wording changes, show that 3 digit octal character constants have less ambiguity.
Diffstat (limited to 'pod/perlrebackslash.pod')
-rw-r--r--pod/perlrebackslash.pod17
1 files changed, 10 insertions, 7 deletions
diff --git a/pod/perlrebackslash.pod b/pod/perlrebackslash.pod
index 386622b58e..5728e7d05a 100644
--- a/pod/perlrebackslash.pod
+++ b/pod/perlrebackslash.pod
@@ -207,12 +207,12 @@ match "as is".
=head3 Octal escapes
-Octal escapes consist of a backslash followed by two or three octal digits
-matching the code point of the character you want to use. This allows for
-512 characters (C<\00> up to C<\777>) that can be expressed this way (but
-anything above C<\377> is deprecated).
-Enough in pre-Unicode days, but most Unicode characters cannot be escaped
-this way.
+Octal escapes consist of a backslash followed by three octal digits
+matching the code point of the character you want to use. (In some contexts,
+two or even one octal digits are also accepted, sometimes with a warning.) This
+allows for 512 characters (C<\000> up to C<\777>) that can be expressed this
+way (but anything above C<\377> is deprecated). Enough in pre-Unicode days,
+but most Unicode characters cannot be escaped this way.
Note that a character that is expressed as an octal escape is considered
as a character without special meaning by the regex engine, and will match
@@ -230,7 +230,10 @@ as a character without special meaning by the regex engine, and will match
Octal escapes potentially clash with old-style backreferences (see L</Absolute
referencing> below). They both consist of a backslash followed by numbers. So
Perl has to use heuristics to determine whether it is a backreference or an
-octal escape. Perl uses the following rules:
+octal escape. You can avoid ambiguity by using the C<\g> form for
+backreferences, and by beginning octal escapes with a "0". (Since octal
+escapes are 3 digits, this latter method works only up to C<\077>.) In the
+absence of C<\g>, Perl uses the following rules:
=over 4