31.6. use charnamesuse charnames HOW; print "\N{CHARSPEC} is a funny character"; This lexically scoped pragma enables named characters to be interpolated into strings using the \N{CHARSPEC} notation: The pragma supports HOW arguments :full and :short, as well as specific script names.[1] The HOW argument determines how the character specified by the CHARSPEC in \N{CHARSPEC}} is to be searched for. If :full is present, the CHARSPEC is first looked for in the Unicode character tables as a complete Unicode character name. If :short is present and CHARSPEC has the form SCRIPTNAME:CHARNAME, CHARNAME is looked for as a letter in script SCRIPTNAME. If HOW contains specific script names, CHARSPEC is looked for as an individual CHARNAME in each of the given scripts, in the specified order.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"; use charnames qw(cyrillic greek); print "\N{sigma} is Greek sigma, and \N{be} is Cyrillic b.\n";
For lookup of CHARNAME inside a given script SCRIPTNAME, the pragma looks in the table of standard Unicode names for patterns of the form: If CHARNAME is entirely lowercase (as in \N{sigma}), the CAPITAL variant is ignored. Otherwise, the SMALL variant is ignored.SCRIPTNAME CAPITAL LETTER CHARNAME SCRIPTNAME SMALL LETTER CHARNAME SCRIPTNAME LETTER CHARNAME You can write your own module that works like the charnames pragma but defines character names differently. However, the interface to that is still experimental, so see the manpage for the latest. Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|