summaryrefslogtreecommitdiff
path: root/pod/perlretut.pod
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-12-18 20:45:14 -0700
committerKarl Williamson <public@khwilliamson.com>2011-12-20 22:02:42 -0700
commitfbb93542d6662666a88828fb4c15803f8ba377f0 (patch)
tree300d9b114ad07a3281c6575d2abb02b7645389b7 /pod/perlretut.pod
parentf8988b416c244747b17eb3004ac6f8bbcf366e7a (diff)
downloadperl-fbb93542d6662666a88828fb4c15803f8ba377f0.tar.gz
Autoload charnames for \N{name}
This autoloads charnames.pm when needed. It uses the :full and :short options. :loose is not used because of its relative unfamiliarity in the Perl community, and is slower. (If someone later added a typical "use charnames qw(:full)", things that previously matched under :loose would start to fail, causing confustion. If :loose does become more common, we can change this in the future to use it; the converse isn't true.) The callable functions in the module are not automatically loaded. To access them, an explicity "use charnames" must be provided. Thanks to Tony Cook for doing a code inspection and finding a missing SPAGAIN.
Diffstat (limited to 'pod/perlretut.pod')
-rw-r--r--pod/perlretut.pod10
1 files changed, 4 insertions, 6 deletions
diff --git a/pod/perlretut.pod b/pod/perlretut.pod
index b2ba390f21..d7e0412456 100644
--- a/pod/perlretut.pod
+++ b/pod/perlretut.pod
@@ -1907,18 +1907,17 @@ specified in the Unicode standard. For instance, if we wanted to
represent or match the astrological sign for the planet Mercury, we
could use
- use charnames ":full"; # use named chars with Unicode full names
$x = "abc\N{MERCURY}def";
$x =~ /\N{MERCURY}/; # matches
-One can also use short names or restrict names to a certain alphabet:
+One can also use "short" names:
- use charnames ':full';
print "\N{GREEK SMALL LETTER SIGMA} is called sigma.\n";
-
- use charnames ":short";
print "\N{greek:Sigma} is an upper-case sigma.\n";
+You can also restrict names to a certain alphabet by specifying the
+L<charnames> pragma:
+
use charnames qw(greek);
print "\N{sigma} is Greek sigma\n";
@@ -1945,7 +1944,6 @@ C<\p{name}> escape sequence. Closely associated is the C<\P{name}>
character class, which is the negation of the C<\p{name}> class. For
example, to match lower and uppercase characters,
- use charnames ":full"; # use named chars with Unicode full names
$x = "BOB";
$x =~ /^\p{IsUpper}/; # matches, uppercase char class
$x =~ /^\P{IsUpper}/; # doesn't match, char class sans uppercase