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

📄 ch19_01.htm

📁 编程珍珠,里面很多好用的代码,大家可以参考学习呵呵,
💻 HTM
📖 第 1 页 / 共 5 页
字号:
directives, since these are considered to occur before the executionof your program.  It no longer executes any <tt class="literal">INIT</tt> or<tt class="literal">END</tt> blocks, however.  The older but rarely usefulbehavior may still be obtained by putting:<blockquote><pre class="programlisting">BEGIN { $^C = 0; exit; }</pre></blockquote>at the end of your main script.</p></dd><dt><b><span class="option">-C</span></b></dt><dd><p><a name="INDEX-3386"></a>Enables Perl to usethe native wide-character APIs on the target system, if supported (asof version 5.6.0 it works on Microsoft platforms only).  The specialvariable <tt class="literal">${^WIDE_SYSTEM_CALLS}</tt> reflects the stateof this switch.</p></dd><dt><b><span class="option">-d</span></b></dt><dd><p><a name="INDEX-3387"></a><a name="INDEX-3388"></a><a name="INDEX-3389"></a><a name="INDEX-3390"></a><a name="INDEX-3391"></a><a name="INDEX-3392"></a>Runs the script under the Perl debugger.  See <a href="ch20_01.htm">Chapter 20, "The Perl Debugger"</a>.</p></dd><dt><b><span class="option">-d:</span><em class="replaceable">MODULE</em></b></dt><dd><p> Runs the script under the control of a debugging ortracing module installed in the Perl library as<tt class="literal">Devel::</tt><em class="replaceable">MODULE</em>.  Forexample, <tt class="userinput"><b>-d:DProf</b></tt> executes the script using the<tt class="literal">Devel::DProf</tt> profiler.  See also the debuggingsection in <a href="ch20_01.htm">Chapter 20, "The Perl Debugger"</a>.</p></dd><dt><b><span class="option">-D</span><em class="replaceable">LETTERS</em></b></dt><dt><b><span class="option">-D</span><em class="replaceable">NUMBER</em></b></dt><dd><p><a name="INDEX-3393"></a><a name="INDEX-3394"></a><a name="INDEX-3395"></a>Sets debugging flags.  (This only works if debugging is compiled intoyour version of Perl as described below.) You may specify either a<em class="replaceable">NUMBER</em> that is the sum of the bits youwant, or a list of <em class="replaceable">LETTERS</em>.  To see how itexecutes your script, for instance, use <span class="option">-D14</span> or<span class="option">-Dslt</span>.  Another useful value is<span class="option">-D1024</span> or <span class="option">-Dx</span>, which lists yourcompiled syntax tree.  And <span class="option">-D512</span> or<span class="option">-Dr</span> displays compiled regular expressions.  Thenumeric value is available internally as the special variable<tt class="literal">$^D</tt>.  <a href="ch19_01.htm#perl2-ch-6-tab-1">Table 19-1</a> lists theassigned bit values.</p><a name="perl2-ch-6-tab-1"></a><h4 class="objtitle">Table 19.1. -D Options</h4><table border="1"><tr><th>Bit</th><th>Letter</th><th>Meaning</th></tr><tr><td><tt class="literal">1</tt></td><td><tt class="literal">p</tt></td><td>Tokenizing and parsing</td></tr><tr><td><tt class="literal">2</tt></td><td><tt class="literal">s</tt></td><td>Stack snapshots</td></tr><tr><td><tt class="literal">4</tt></td><td><tt class="literal">l</tt></td><td>Label stack processing</td></tr><tr><td><tt class="literal">8</tt></td><td><tt class="literal">t</tt></td><td>Trace execution</td></tr><tr><td><tt class="literal">16</tt></td><td><tt class="literal">o</tt></td><td>Method and overloading resolution</td></tr><tr><td><tt class="literal">32</tt></td><td><tt class="literal">c</tt></td><td>String/numeric conversions</td></tr><tr><td><tt class="literal">64</tt></td><td><tt class="literal">P</tt></td><td>Print preprocessor command for <span class="option">-P</span></td></tr><tr><td><tt class="literal">128</tt></td><td><tt class="literal">m</tt></td><td>Memory allocation</td></tr><tr><td><tt class="literal">256</tt></td><td><tt class="literal">f</tt></td><td>Format processing</td></tr><tr><td><tt class="literal">512</tt></td><td><tt class="literal">r</tt></td><td>Regex parsing and execution</td></tr><tr><td><tt class="literal">1024</tt></td><td><tt class="literal">x</tt></td><td>Syntax tree dump</td></tr><tr><td><tt class="literal">2048</tt></td><td><tt class="literal">u</tt></td><td>Tainting checks</td></tr><tr><td><tt class="literal">4096</tt></td><td><tt class="literal">L</tt></td><td>Memory leaks (needs <span class="option">-DLEAKTEST</span> when compiling Perl)</td></tr><tr><td><tt class="literal">8192</tt></td><td><tt class="literal">H</tt></td><td>Hash dump--usurps <tt class="literal">values()</tt></td></tr><tr><td><tt class="literal">16384</tt></td><td><tt class="literal">X</tt></td><td>Scratchpad allocation</td></tr><tr><td><tt class="literal">32768</tt></td><td><tt class="literal">D</tt></td><td>Cleaning up</td></tr><tr><td><tt class="literal">65536</tt></td><td><tt class="literal">S</tt></td><td>Thread synchronization</td></tr></table><p><a name="INDEX-3396"></a>All these flags require a Perl executable that was specially built fordebugging.  However, because this is not the default, you won't beable to use the <span class="option">-D</span> switch at all unless you or yoursysadmin built this special debugging version of Perl.  See the<em class="emphasis">INSTALL</em> file in the Perl source directory fordetails, but the short story is that you need to pass<span class="option">-DDEBUGGING</span> to your C compiler whencompiling Perl itself.  This flag is automatically set if you includethe <span class="option">-g</span> option when <em class="emphasis">Configure</em>asks you about optimizer and debugger flags.</p><p>If you're just trying to get a printout of each line of Perl codeas it executes (the way that <em class="emphasis">sh -x</em> provides for shell scripts),you can't use Perl's <span class="option">-D</span> switch.  Instead do this:<blockquote><pre class="programlisting"># Bourne shell syntax$ <tt class="userinput"><b>PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program</b></tt># csh syntax<tt class="computeroutput">%</tt> <tt class="userinput"><b>(setenv PERLDB_OPTS "NonStop=1 AutoTrace=1 frame=2"; perl -dS program)</b></tt></pre></blockquote>See <a href="ch20_01.htm">Chapter 20, "The Perl Debugger"</a> for details and variations.</p></dd><dt><b><span class="option">-e</span> <em class="replaceable">PERLCODE</em></b></dt><dd><p><a name="INDEX-3397"></a><a name="INDEX-3398"></a><a name="INDEX-3399"></a><a name="INDEX-3400"></a>May be used to enter one or more lines of script.  If <span class="option">-e</span> is used,Perl will not look for the program's filename in the argument list.The <em class="replaceable">PERLCODE</em> argument is treated as if it ended with a newline, somultiple <span class="option">-e</span> commands may be given to build up a multiline program.(Make sure to use semicolons where you would in a normal program storedin a file.)  Just because <span class="option">-e</span> supplies a newline on each argumentdoesn't imply that you must use multiple <span class="option">-e</span> switches; if your shellsupports multiline quoting like <em class="emphasis">sh</em>, <em class="emphasis">ksh</em>, or <em class="emphasis">bash</em>, you maypass a multiline script as one <span class="option">-e</span> argument:<blockquote><pre class="programlisting"><tt class="computeroutput">$</tt> <tt class="userinput"><b>perl -e 'print "Howdy, ";           print "@ARGV!\n";' world</b></tt>Howdy, world!</pre></blockquote>With <em class="emphasis">csh</em> it's probably better to use multiple <span class="option">-e</span> switches:<blockquote><pre class="programlisting"><tt class="computeroutput">%</tt> <tt class="userinput"><b>perl -e 'print "Howdy, ";' \       -e 'print "@ARGV!\n";' world</b></tt>Howdy, world!</pre></blockquote>Both implicit and explicit newlines count in the line numbering, so thesecond print is on line 2 of the <span class="option">-e</span> script in either case.</p></dd><dt><b><span class="option">-F</span><em class="replaceable">PATTERN</em></b></dt><dd><p><a name="INDEX-3401"></a><a name="INDEX-3402"></a><a name="INDEX-3403"></a>Specifies the pattern to <tt class="literal">split</tt> on when autosplitting via the<span class="option">-a</span> switch (has no effect otherwise).  The pattern may be surroundedby slashes (<tt class="literal">//</tt>), double quotes (<tt class="literal">""</tt>), or single quotes (<tt class="literal">''</tt>).Otherwise, it will be automatically put in single quotes.  Rememberthat to pass quotes through a shell, you'll have to quote yourquotes, and how you can do that depends on the shell.<a name="INDEX-3404"></a></p></dd><dt><b><span class="option">-h</span></b></dt><dd><p><a name="INDEX-3405"></a><a name="INDEX-3406"></a>Prints a summary of Perl's command-line options.</p></dd><dt><b><span class="option">-i</span><em class="replaceable">EXTENSION</em></b></dt><dt><b><span class="option">-i</span></b></dt><dd><p><a name="INDEX-3407"></a><a name="INDEX-3408"></a><a name="INDEX-3409"></a><a name="INDEX-3410"></a>Specifies that files processed by the <tt class="literal">&lt;&gt;</tt> construct areto be edited in place.  It does this by renaming the input file,opening the output file by the original name, and selecting thatoutput file as the default for calls to <tt class="literal">print</tt>, <tt class="literal">printf</tt>, and<tt class="literal">write</tt>.<a href="#FOOTNOTE-4">[4]</a></p><blockquote class="footnote"><a name="FOOTNOTE-4"></a><p>[4]Technically, this isn't really "in place".  It'sthe same filename, but a different physical file.</p></blockquote><p>The <em class="replaceable">EXTENSION</em> is used to modify the name of the old file to makea backup copy.  If no <em class="replaceable">EXTENSION</em> is supplied, no backup is madeand the current file is overwritten.  If the <em class="replaceable">EXTENSION</em> doesn'tcontain a <tt class="literal">*</tt>, then that string is appended to the end of thecurrent filename.  If the <em class="replaceable">EXTENSION</em> does contain one or more<tt class="literal">*</tt> characters, then each <tt class="literal">*</tt> is replaced by the filename currentlybeing processed.  In Perl terms, you could think of this as:<blockquote><pre class="programlisting">($backup = $extension) =~ s/\*/$file_name/g;</pre></blockquote>This allows you to use a prefix for the backup file, instead of--or even inaddition to--a suffix:<blockquote><pre class="programlisting"><tt class="computeroutput">%</tt> <tt class="userinput"><b>perl -pi'orig_*' -e 's/foo/bar/' xyx</b></tt>     # backup to 'orig_xyx'</pre></blockquote>

⌨️ 快捷键说明

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