本文介绍了如何在<中运行`x`命令。在perl调试器中执行操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试器中显示提示之前,我想输出一个半复杂的结构。最好的显示方法是使用 x 命令,但是该命令在该名称下不可用,或者可能不在范围内。

I'd like to get a semicomplex structure to be output before displaying the prompt in the debugger. The best way to display it is to use the x command, but the command isn't available under that name or perhaps it's not in scope.

我将如何实现?

推荐答案

请参见文档< ; rel = noreferrer> perldebug :

See the documentation for < [command] in perldebug:

设置在每个调试器提示之前执行的操作(Perl命令)。

Set an action (Perl command) to happen before every debugger prompt.

x 不是Perl命令。您要 {[命令]

x is not a Perl command. You want { [command]:

设置在每个调试器提示之前执行的操作(调试器命令)。

Set an action (debugger command) to happen before every debugger prompt.

例如:

$ perl -de'$foo = { foo => "bar" };
           print $foo'

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(-e:1):   $foo = { foo => "bar" };
  DB<1> { x $foo
  DB<2> n
main::(-e:2):   print $foo
auto(-1)  DB<2> x $foo
0  HASH(0x22af2c8)
   'foo' => 'bar'

或者,使用您喜欢的转储模块(例如,,):

Alternatively, use your favorite dumper module (e.g. Data::Dumper, Data::Dump, Data::Printer):

$ perl -de'$foo = { foo => "bar" };
           print $foo'

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(-e:1):   $foo = { foo => "bar" };
  DB<1> use Data::Dumper

  DB<2> < print Dumper $foo
  DB<3> n
main::(-e:2):   print $foo
$VAR1 = {
          'foo' => 'bar'
        };

这篇关于如何在&lt;中运行`x`命令。在perl调试器中执行操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:34