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

📄 ch20_02.htm

📁 编程珍珠,里面很多好用的代码,大家可以参考学习呵呵,
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<a name="INDEX-3539"></a>This command toggles trace mode, which prints out every line in yourprogram as it is evaluated.  See also the <tt class="literal">AutoTrace</tt> option discussed later in this chapter.If an <em class="replaceable">EXPR</em> is provided, the debugger will trace through itsexecution.  See also the later section <a href="ch20_04.htm#ch20-sect-ue">Section 20.4, "Unattended Execution"</a>.</p></dd><dt><b><tt class="literal">W</tt></b></dt><dt><b><tt class="literal">W</tt> <em class="replaceable">EXPR</em></b></dt><dd><p><a name="INDEX-3540"></a><a name="INDEX-3541"></a>This command adds <em class="replaceable">EXPR</em> as a global watch expression.  (A watchexpression is an expression that will cause a breakpoint when its value changes.)If no <em class="replaceable">EXPR</em> is provided, all watch expressions are deleted.</p></dd></dl><h3 class="sect2">20.2.4. Display</h3><p><a name="INDEX-3542"></a><a name="INDEX-3543"></a>Perl's debugger has several commands for examining data structureswhile your program is stopped at a breakpoint.</p><dl><dt><b><tt class="literal">p</tt></b></dt><dt><b><tt class="literal">p</tt> <em class="replaceable">EXPR</em></b></dt><dd><p><a name="INDEX-3544"></a><a name="INDEX-3545"></a>This command is the same as <tt class="literal">print DB::OUT</tt><em class="replaceable">EXPR</em> in the currentpackage.  In particular, since this is just Perl's own <tt class="literal">print</tt>function, nested data structures and objects are not shown--usethe <tt class="literal">x</tt> command for that. The <tt class="literal">DB::OUT</tt> handle prints to your terminal (or perhaps an editor window) no matter where standardoutput may have been redirected.</p></dd><dt><b><tt class="literal">x</tt></b></dt><dt><b><tt class="literal">x</tt> <em class="replaceable">EXPR</em></b></dt><dd><p><a name="INDEX-3546"></a>The <tt class="literal">x</tt> command evaluates its expression in list context and displays the result, pretty-printed.  That is, nested data structures areprinted out recursively and with unviewable characters suitablyencoded.</p></dd><dt><b><tt class="literal">V</tt></b></dt><dt><b><tt class="literal">V</tt> <em class="replaceable">PKG</em></b></dt><dt><b><tt class="literal">V</tt> <em class="replaceable">PKG</em> <em class="replaceable">VARS</em></b></dt><dd><p><a name="INDEX-3547"></a>This command displays all (or when you specify <em class="replaceable">VARS</em>, some) variablesin the specified <em class="replaceable">PKG</em> (defaulting to the <tt class="literal">main</tt> package) using apretty printer.  Hashes show their keys and values, control charactersare rendered legibly, nested data structures print out in a legiblefashion, and so on.  This is similar to calling the <tt class="literal">x</tt> command oneach applicable variable, except that <tt class="literal">x</tt> works with lexicalvariables, too.  Also, here you type the identifiers <em class="emphasis">without</em> a typespecifier such as <tt class="literal">$</tt> or <tt class="literal">@</tt>, like this:<blockquote><pre class="programlisting">V Pet::Camel SPOT FIDO</pre></blockquote>In place of a variable name in <em class="replaceable">VARS</em>, you can use <tt class="literal">~</tt><em class="replaceable">PATTERN</em> or<tt class="literal">!</tt><em class="replaceable">PATTERN</em> to print existing variables whose names either match ordon't match the specified pattern.</p></dd><dt><b><tt class="literal">X</tt></b></dt><dt><b><tt class="literal">X</tt> <em class="replaceable">VARS</em></b></dt><dd><p>This command is the same as <tt class="literal">V</tt><em class="replaceable">CURRENTPACKAGE</em>, where<em class="replaceable">CURRENTPACKAGE</em> is the package that the current line was compiledinto.</p></dd><dt><b><tt class="literal">H</tt></b></dt><dt><b><tt class="literal">H</tt> -<em class="replaceable">NUMBER</em></b></dt><dd><p>This command displays the last <em class="replaceable">NUMBER</em> commands.  Only commands longer than one character are stored in the history.  (Most of themwould be <tt class="literal">s</tt> or <tt class="literal">n</tt>, otherwise.) If <em class="replaceable">NUMBER</em> is omitted, all commandsare listed.</p></dd></dl><h3 class="sect2">20.2.5. Locating Code</h3><p><a name="INDEX-3548"></a><a name="INDEX-3549"></a>Inside the debugger, you can extract and display parts of your programwith these commands.</p><dl><dt><b><tt class="literal">l</tt></b></dt><dt><b><tt class="literal">l</tt> <em class="replaceable">LINE</em></b></dt><dt><b><tt class="literal">l</tt> <em class="replaceable">SUBNAME</em></b></dt><dt><b><tt class="literal">l</tt> <em class="replaceable">MIN</em>+<em class="replaceable">INCR</em></b></dt><dt><b><tt class="literal">l</tt> <em class="replaceable">MIN-MAX</em></b></dt><dd><p><a name="INDEX-3550"></a>The <tt class="literal">l</tt> command lists next the few lines of your program, or the specified <em class="replaceable">LINE</em> if provided, or the first few lines of the <em class="replaceable">SUBNAME</em> subroutine or code reference.</p><p>The <tt class="literal">l</tt><em class="replaceable">MIN+INCR</em> form lists <em class="replaceable">INCR</em><tt class="literal">+1</tt> lines, starting at<em class="replaceable">MIN</em>.  The <tt class="literal">l</tt><em class="replaceable">MIN-MAX</em> form lists lines <em class="replaceable">MIN</em> through <em class="replaceable">MAX</em>.</p></dd><dt><b><tt class="literal">-</tt></b></dt><dd><p><a name="INDEX-3551"></a>This command lists the previous few lines of your program.</p></dd><dt><b><tt class="literal">w</tt></b></dt><dt><b><tt class="literal">w</tt> <em class="replaceable">LINE</em></b></dt><dd><p>Lists a window (a few lines) around the given source <em class="replaceable">LINE</em>, or the current line if no <em class="replaceable">LINE</em> is supplied.</p></dd><dt><b><tt class="literal">f</tt> <em class="replaceable">FILENAME</em></b></dt><dd><p><a name="INDEX-3552"></a>This command lets you view a different program or <tt class="literal">eval</tt> statement. If the <em class="replaceable">FILENAME</em> is not a full pathname as found in the values of <tt class="literal">%INC</tt>,it is interpreted as a regular expression to find the filename you mean.</p></dd><dt><b><tt class="literal">/</tt><em class="replaceable">PATTERN</em><tt class="literal">/</tt></b></dt><dd><p><a name="INDEX-3553"></a><a name="INDEX-3554"></a><a name="INDEX-3555"></a>This command searches forward in the program for <em class="replaceable">PATTERN</em>; the final<tt class="literal">/</tt> is optional.  The entire <em class="replaceable">PATTERN</em> is optional, too, and ifomitted, repeats the previous search.</p></dd><dt><b><tt class="literal">?</tt><em class="replaceable">PATTERN</em><tt class="literal">?</tt></b></dt><dd><p><a name="INDEX-3556"></a>This command searches backward for <em class="replaceable">PATTERN</em>; the final <tt class="literal">?</tt> isoptional.  It repeats the previous search if <em class="replaceable">PATTERN</em> is omitted.</p></dd><dt><b><tt class="literal">S</tt></b></dt><dt><b><tt class="literal">S</tt> <em class="replaceable">PATTERN</em></b></dt><dt><b><tt class="literal">S !</tt><em class="replaceable">PATTERN</em></b></dt><dd><p><a name="INDEX-3557"></a>The <tt class="literal">S</tt> command lists those subroutine names matching (or, with <tt class="literal">!</tt>, thosenot matching) <em class="replaceable">PATTERN</em>. If no <em class="replaceable">PATTERN</em> is provided, allsubroutines are listed.</p></dd></dl><h3 class="sect2">20.2.6. Actions and Command Execution</h3><p><a name="INDEX-3558"></a><a name="INDEX-3559"></a>From inside the debugger, you can specify actions to be takenat particular times. You can also launch external programs.</p><dl><dt><b><tt class="literal">a</tt></b></dt><dt><b><tt class="literal">a</tt> <em class="replaceable">COMMAND</em></b></dt><dt><b><tt class="literal">a</tt> <em class="replaceable">LINE</em></b></dt><dt><b><tt class="literal">a</tt> <em class="replaceable">LINE</em> <em class="replaceable">COMMAND</em></b></dt><dd><p>This command sets an action to take before<em class="replaceable">LINE</em> executes, or the current line if<em class="replaceable">LINE</em> is omitted.  For example, this printsout <tt class="literal">$foo</tt> every time line 53 is reached:</p><p><blockquote><pre class="programlisting">a 53 print "DB FOUND $foo\n"</pre></blockquote>If no <tt class="literal">COMMAND</tt> is specified, the action on thespecified <em class="replaceable">LINE</em> is deleted.  With neither<em class="replaceable">LINE</em> nor<em class="replaceable">COMMAND</em>, the action on the current line isdeleted.</p></dd><dt><b><tt class="literal">A</tt></b></dt><dd><p><a name="INDEX-3560"></a><a name="INDEX-3561"></a>The <tt class="literal">A</tt> debugger command deletes all actions.</p></dd><dt><b><tt class="literal">&lt;</tt></b></dt><dt><b><tt class="literal">&lt; ?</tt></b></dt><dt><b><tt class="literal">&lt;</tt> <em class="replaceable">EXPR</em></b></dt><dt><b><tt class="literal">&lt;&lt;</tt> <em class="replaceable">EXPR</em></b></dt><dd><p>The <tt class="literal">&lt;</tt><em class="replaceable">EXPR</em> formspecifies a Perl expression to be evaluated before every debuggerprompt.  You can add another expression with the<tt class="literal">&lt;&lt;</tt><em class="replaceable">EXPR</em> form, listthem with <tt class="literal">&lt; ?</tt>, and delete them all with a plain<tt class="literal">&lt;</tt>.</p></dd>

⌨️ 快捷键说明

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