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

📄 ch04_04.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<dd><a name="INDEX-369" /><a name="INDEX-370" />The internalflag that the debugger clears so that it doesn'tdebug itself.</p></dd><dt><b><tt class="literal">$^T</tt></b></dt><dt><b><tt class="literal">$BASETIME</tt></b></dt><dd><a name="INDEX-371" /><a name="INDEX-372" />The time atwhich the script began running, in seconds since the epoch.</p></dd><dt><b><tt class="literal">$^W</tt></b></dt><dt><b><tt class="literal">$WARNING</tt></b></dt><dd><a name="INDEX-373" /><a name="INDEX-374" />The currentvalue of the warning switch, either true or false.</p></dd><dt><b><tt class="literal">$^X</tt></b></dt><dt><b><tt class="literal">$EXECUTABLE_NAME</tt></b></dt><dd><a name="INDEX-375" /><a name="INDEX-376" />The name that the Perl binary itselfwas executed as. As of Perl 5.8, Perl asks the operating systeminstead of using C's <tt class="literal">argv[0]</tt>.</p></dd><dt><b><tt class="literal">$ARGV</tt></b></dt><dd><a name="INDEX-377" />Contains the name of the current filewhen reading from <tt class="literal">&lt;ARGV&gt;</tt>.</p></dd></dl></div><a name="perlnut2-CHP-4-SECT-4.2" /><div class="sect2"><h3 class="sect2">4.4.2. Global Special Arrays and Hashes</h3><a name="INDEX-378" /><a name="INDEX-379" /><dl><dt><b><tt class="literal">@ARGV</tt></b></dt><dd><a name="INDEX-380" />The array containing the command-linearguments intended for the script.</p></dd><dt><b><tt class="literal">@INC</tt></b></dt><dd><a name="INDEX-381" />The array containing the list of places tolook for Perl scripts to be evaluated by the <tt class="literal">do</tt>,<tt class="literal">require</tt>, or <tt class="literal">use</tt> constructs.</p></dd><dt><b><tt class="literal">@F</tt></b></dt><dd><a name="INDEX-382" />The array into which the input lines aresplit when the <em class="emphasis">-a</em> command-line switch is given.</p></dd><dt><b><tt class="literal">%INC</tt></b></dt><dd><a name="INDEX-383" />The hash containing entries for thefilename of each file that has been included via<tt class="literal">do</tt> or <tt class="literal">require</tt>.</p></dd><dt><b><tt class="literal">%ENV</tt></b></dt><dd><a name="INDEX-384" />The hash containing your currentenvironment.</p></dd><dt><b><tt class="literal">%SIG</tt></b></dt><dd><a name="INDEX-385" />The hash used to set signal handlers forvarious signals.</p></dd></dl></div><a name="perlnut2-CHP-4-SECT-4.3" /><div class="sect2"><h3 class="sect2">4.4.3. Global Special Filehandles</h3><a name="INDEX-386" /><dl><dt><b><tt class="literal">ARGV</tt></b></dt><dd><a name="INDEX-387" />The specialfilehandle that iterates over command-line filenames in<tt class="literal">@ARGV</tt>. Usually written as the null filehandle in<tt class="literal">&lt;&gt;</tt>.</p></dd><dt><b><tt class="literal">STDERR</tt></b></dt><dd><a name="INDEX-388" />Thespecial filehandle for standard error in any package.</p></dd><dt><b><tt class="literal">STDIN</tt></b></dt><dd><a name="INDEX-389" />The specialfilehandle for standard input in any package.</p></dd><dt><b><tt class="literal">STDOUT</tt></b></dt><dd><a name="INDEX-390" />Thespecial filehandle for standard output in any package.</p></dd><dt><b><tt class="literal">DATA</tt></b></dt><dd><a name="INDEX-391" />The specialfilehandle that refers to anything following the <tt class="literal">_ _END__</tt> token in the file containing the script. Or the specialfilehandle for anything following the <tt class="literal">_ _DATA_ _</tt>token in a required file, as long as you're readingdata in the same package <tt class="literal">_ _DATA_ _</tt> was found in.</p></dd><dt><b><tt class="literal">_</tt> (underscore)</b></dt><dd><a name="INDEX-392" /><a name="INDEX-393" />The specialfilehandle used to cache the information from the last<tt class="literal">stat</tt>, <tt class="literal">lstat</tt>, or file testoperator.</p></dd></dl></div><a name="perlnut2-CHP-4-SECT-4.4" /><div class="sect2"><h3 class="sect2">4.4.4. Global Special Constants</h3><a name="INDEX-394" /><dl><dt><b><tt class="literal">_  _END_  _</tt></b></dt><dd><a name="INDEX-395" /> <a name="INDEX-396" />Indicates thelogical end of your program. Any following text is ignored, but maybe read via the <tt class="literal">DATA</tt> filehandle.</p></dd><dt><b><tt class="literal">_  _FILE_  _</tt></b></dt><dd><a name="INDEX-397" /> <a name="INDEX-398" />Represents thefilename at the point in your program where it'sused. Not interpolated into strings.</p></dd><dt><b><tt class="literal">_  _LINE_  _</tt></b></dt><dd><a name="INDEX-399" /> <a name="INDEX-400" />Represents thecurrent line number. Not interpolated into strings.</p></dd><dt><b><tt class="literal">_  _PACKAGE_  _</tt></b></dt><dd><a name="INDEX-401" /> <a name="INDEX-402" />Represents the current package name atcompile time, or undefined if there is no current package. Notinterpolated into strings.</p></dd></dl></div><a name="perlnut2-CHP-4-SECT-4.5" /><div class="sect2"><h3 class="sect2">4.4.5. Regular Expression Special Variables</h3><p><a name="INDEX-403" />For more information onregular expressions, see <a href="ch04_06.htm#perlnut2-CHP-4-SECT-6">Section 4.6, "Regular Expressions"</a> later in this chapter.</p><dl><dt><b><tt class="literal">$</tt><em class="replaceable">digit</em></b></dt><dd><a name="INDEX-404" />Contains the text matched by thecorresponding set of parentheses in the last pattern matched. Forexample, <tt class="literal">$1</tt> matches whatever was contained in thefirst set of parentheses in the previous regular expression.</p></dd><dt><b><tt class="literal">$&amp;</tt></b></dt><dt><b><tt class="literal">$MATCH</tt></b></dt><dd><a name="INDEX-405" /><a name="INDEX-406" />The stringmatched by the last successful pattern match.</p></dd><dt><b><tt class="literal">$'</tt></b></dt><dt><b><tt class="literal">$PREMATCH</tt></b></dt><dd><a name="INDEX-407" /><a name="INDEX-408" />The stringpreceding whatever was matched by the last successful pattern match.</p></dd><dt><b><tt class="literal">$'</tt></b></dt><dt><b><tt class="literal">$POSTMATCH</tt></b></dt><dd><a name="INDEX-409" /><a name="INDEX-410" />Thestring following whatever was matched by the last successful patternmatch.</p></dd><dt><b><tt class="literal">$+</tt></b></dt><dt><b><tt class="literal">$LAST_PAREN_MATCH</tt></b></dt><dd><a name="INDEX-411" /><a name="INDEX-412" />The last bracket matched by the lastsearch pattern. This is useful if you don't knowwhich of a set of alternative patterns was matched. For example:</p><blockquote><pre class="code">/Version: (.*)|Revision: (.*)/ &amp;&amp; ($rev = $+);</pre></blockquote></dd><a name="INDEX-413" /><dt><b><tt class="literal">$^N</tt></b></dt><dd>The string matched by the most recently closed group. This is mostuseful inside <tt class="literal">(?{</tt> . . . <tt class="literal">})</tt>blocks for examining matched text. If you have multiple matchesdenoted by parentheses, <tt class="literal">$^N</tt> can be used in lieu of<tt class="literal">$1</tt>, <tt class="literal">$2</tt>, <tt class="literal">$3</tt>,etc., so you don't have to manually count the numberof sets of parentheses that denote your matches. For example:</p><blockquote><pre class="code">#!/usr/local/bin/perl -w$words = "person|here";$words =~ /(\w+)\|(\w+)/;print $^N;   # Prints 'here'</pre></blockquote></dd></dl></div><a name="perlnut2-CHP-4-SECT-4.6" /><div class="sect2"><h3 class="sect2">4.4.6. Filehandle Special Variables</h3><p><a name="INDEX-414" />Most of these variables applyonly when using formats. See <a href="ch04_11.htm#perlnut2-CHP-4-SECT-11">Section 4.11, "Unicode"</a> later in this chapter.</p><dl><dt><b><tt class="literal">$|</tt></b></dt><dt><b><tt class="literal">$OUTPUT_AUTOFLUSH</tt></b></dt><dd><a name="INDEX-415" /><a name="INDEX-416" />If set to nonzero, forces an<tt class="literal">fflush(3)</tt> after every <tt class="literal">write</tt> or<tt class="literal">print</tt> on the currently selected output channel.</p></dd><dt><b><tt class="literal">$%</tt></b></dt><dt><b><tt class="literal">$FORMAT_PAGE_NUMBER</tt></b></dt><dd><a name="INDEX-417" /><a name="INDEX-418" />The current page number of thecurrently selected output channel.</p></dd><dt><b><tt class="literal">$=</tt></b></dt><dt><b><tt class="literal">$FORMAT_LINES_PER_PAGE</tt></b></dt><dd><a name="INDEX-419" /><a name="INDEX-420" />The current page length (printablelines) of the currently selected output channel. Default is 60.</p></dd><dt><b><tt class="literal">$-</tt></b></dt><dt><b><tt class="literal">$FORMAT_LINES_LEFT</tt></b></dt><dd><a name="INDEX-421" /><a name="INDEX-422" />The number of lines left on the page ofthe currently selected output channel.</p></dd><dt><b><tt class="literal">$~</tt></b></dt><dt><b><tt class="literal">$FORMAT_NAME</tt></b></dt><dd><a name="INDEX-423" /><a name="INDEX-424" />The name of the current report formatfor the currently selected output channel. Default is the name of thefilehandle.</p></dd><dt><b><tt class="literal">$^</tt></b></dt><dt><b><tt class="literal">$FORMAT_TOP_NAME</tt></b></dt><dd><a name="INDEX-425" /><a name="INDEX-426" />The name of the current top-of-pageformat for the currently selected output channel. Default is the nameof the filehandle with <tt class="literal">_TOP</tt> appended.</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch04_03.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch04_05.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">4.3. Statements</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">4.5. Operators</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

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