⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch31_06.htm

📁 编程珍珠,里面很多好用的代码,大家可以参考学习呵呵,
💻 HTM
字号:
<html><head><title>use charnames (Programming Perl)</title><!-- STYLESHEET --><link rel="stylesheet" type="text/css" href="../style/style1.css"><!-- METADATA --><!--Dublin Core Metadata--><meta name="DC.Creator" content=""><meta name="DC.Date" content=""><meta name="DC.Format" content="text/xml" scheme="MIME"><meta name="DC.Generator" content="XSLT stylesheet, xt by James Clark"><meta name="DC.Identifier" content=""><meta name="DC.Language" content="en-US"><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="use charnames"><meta name="DC.Type" content="Text.Monograph"></head><body><!-- START OF BODY --><!-- TOP BANNER --><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home"><map name="banner-map"><AREA SHAPE="RECT" COORDS="0,0,466,71" HREF="index.htm" ALT="Programming Perl"><AREA SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"></map><!-- TOP NAV BAR --><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch31_05.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="ch31_01.htm">Chapter 31: Pragmatic Modules</a></td><td align="right" valign="top" width="172"><a href="ch31_07.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h2 class="sect1">31.6. use charnames</h2><blockquote><pre class="programlisting">use charnames <em class="replaceable">HOW</em>;print "\N{<em class="replaceable">CHARSPEC</em>} is a funny character";</pre></blockquote><p>This lexically scoped pragma enables named characters to be interpolated into strings using the<tt class="literal">\N{</tt><em class="replaceable">CHARSPEC</em><tt class="literal">}</tt> notation:<blockquote><pre class="programlisting">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";</pre></blockquote>The pragma supports <em class="replaceable">HOW</em> arguments <tt class="literal">:full</tt> and <tt class="literal">:short</tt>, as well asspecific script names.<a href="#FOOTNOTE-1">[1]</a> The <em class="replaceable">HOW</em> argument determines howthe character specified by the <em class="replaceable">CHARSPEC</em> in<tt class="literal">\N{</tt><em class="replaceable">CHARSPEC</em><tt class="literal">}}</tt>is to be searched for.  If <tt class="literal">:full</tt> is present, the <em class="replaceable">CHARSPEC</em> isfirst looked for in the Unicode character tables as a complete Unicodecharacter name.  If <tt class="literal">:short</tt> is present and <em class="replaceable">CHARSPEC</em> has the form<em class="replaceable">SCRIPTNAME</em><tt class="literal">:</tt><em class="replaceable">CHARNAME</em>,<em class="replaceable">CHARNAME</em> is looked for as a letter inscript <em class="replaceable">SCRIPTNAME</em>.  If <em class="replaceable">HOW</em> contains specific script names,<tt class="literal">CHARSPEC</tt> is looked for as an individual <em class="replaceable">CHARNAME</em> in each of the givenscripts, in the specified order.</p><blockquote class="footnote"><a name="FOOTNOTE-1"></a><p>[1] By which we don't mean Perl scripts. We mean "script" as in some particular style of written letters, likeRoman or Greek or Cyrillic.  Unfortunately, "script" is the technicalterm for that, and we're not likely to persuade the Unicode Consortiumto use a different term.</p></blockquote><p>For lookup of <em class="replaceable">CHARNAME</em> inside a given script <em class="replaceable">SCRIPTNAME</em>,the pragma looks in the table of standard Unicode names for patternsof the form:<blockquote><pre class="programlisting"><em class="replaceable">SCRIPTNAME</em> CAPITAL LETTER <em class="replaceable">CHARNAME</em><em class="replaceable">SCRIPTNAME</em> SMALL LETTER <em class="replaceable">CHARNAME</em><em class="replaceable">SCRIPTNAME</em> LETTER <em class="replaceable">CHARNAME</em></pre></blockquote>If <em class="replaceable">CHARNAME</em> is entirely lowercase (as in <tt class="literal">\N{sigma}</tt>), the <tt class="literal">CAPITAL</tt> variant isignored.  Otherwise, the <tt class="literal">SMALL</tt> variant is ignored.</p><p>You can write your own module that works like the <tt class="literal">charnames</tt> pragmabut defines character names differently.  However, the interface to that isstill experimental, so see the manpage for the latest.</p><!-- BOTTOM NAV BAR --><hr width="515" align="left"><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch31_05.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0"></a></td><td align="right" valign="top" width="172"><a href="ch31_07.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr><tr><td align="left" valign="top" width="172">31.5. use bytes</td><td align="center" valign="top" width="171"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0"></a></td><td align="right" valign="top" width="172">31.7. use constant</td></tr></table></div><hr width="515" align="left"><!-- LIBRARY NAV BAR --><img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2001</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"> <area shape="rect" coords="2,-1,79,99" href="../index.htm"><area shape="rect" coords="84,1,157,108" href="../perlnut/index.htm"><area shape="rect" coords="162,2,248,125" href="../prog/index.htm"><area shape="rect" coords="253,2,326,130" href="../advprog/index.htm"><area shape="rect" coords="332,1,407,112" href="../cookbook/index.htm"><area shape="rect" coords="414,2,523,103" href="../sysadmin/index.htm"></map><!-- END OF BODY --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -