是否有相当于 perl 调试器 'x' 的工具?在pdl2(或Devel::REPL)中?
我也使用 pdl2
(PDL
shell)我的默认 Perl 交互式 shell(它加载 Devel::REPL 的所有不错的插件
)。但我缺少 x
dumper-printing 别名。 p
对于 piddle 来说很好,但对于普通的数组引用或哈希引用不起作用。我已经加载了 Data::Dumper
但它缺乏一种简单的方法控制深度,我喜欢使用 x
快速设置深度限制的方式,例如对于复杂数据结构的 x 2 $deep_datastruct
。但使用 Data::Dumper
过程就更麻烦了:
pdl> say $c
HASH(0x53b0b60)
pdl> p $c
HASH(0x12b14018)
pdl> use Data::Dumper
pdl> p Dumper $c
$VAR1 = {
'c' => {
'c' => 3,
'a' => 1,
'b' => {
'c' => '3',
'a' => '1',
'b' => '2'
}
},
'a' => 1,
'b' => 4
};
pdl> $Data::Dumper::Maxdepth = 1;
pdl> p Dumper $c
$VAR1 = {
'c' => 'HASH(0x97fba70)',
'a' => 1,
'b' => 4
};
在 Perl 调试器 中,你可以直接使用 x 1 $c
实现同样的效果。 pdl2
有类似且简洁的东西吗?
[更新] 与这个问题相关:pdl2
或 Devel::REPL
是否具有像 Perl 调试器命令 m
或 y
这样的便利功能代码>?或者应该使用 PadWalker
创建一个模块并导出它们?我想使用真正的 REPL 而不是 Perl 调试器作为交互式 shell,但 Perl 调试器仍然有一些重要的事情,我不知道如何使用 Devel::REPL
或 <代码>pdl2。
例如,查看所有变量(pdl2
仅显示 piddles):
pdl> help vars
PDL variables in package main::
Name Type Dimension Flow State Mem
----------------------------------------------------------------
no PDL objects in package main::
顺便说一句,有人知道一个 Devel::REPL
插件用于列出所有正在使用的变量(例如 < code>y 在调试器中,但只有名称,而不是值),然后有一个 x
之类的来转储想要的?
I am using pdl2
(the PDL
shell) also as a my default Perl interactive shell (it loads all the nice plugins for Devel::REPL
). But I am missing the x
dumper-printing alias. p
is nice for piddles but it does not work for a normal array ref or hash ref. I have loaded Data::Dumper
but it lacks an easy way of controlling depth and I like the way you can quickly set depth limits with x
, e.g. x 2 $deep_datastruct
for complex data structures. But with Data::Dumper
the process is more cumbersome:
pdl> say $c
HASH(0x53b0b60)
pdl> p $c
HASH(0x12b14018)
pdl> use Data::Dumper
pdl> p Dumper $c
$VAR1 = {
'c' => {
'c' => 3,
'a' => 1,
'b' => {
'c' => '3',
'a' => '1',
'b' => '2'
}
},
'a' => 1,
'b' => 4
};
pdl> $Data::Dumper::Maxdepth = 1;
pdl> p Dumper $c
$VAR1 = {
'c' => 'HASH(0x97fba70)',
'a' => 1,
'b' => 4
};
In the Perl debugger you can achieve the same thing with x 1 $c
directly. Does pdl2
have something similar and so concise?
[update]
And related with this question: does pdl2
or Devel::REPL
have convenience functions like the Perl debugger commands m
or y
? Or should one create a module with PadWalker
and export them? I would like to use a real REPL instead of the Perl debugger as an interactive shell, but still the Perl debugger has some important things that I don't know how to do with Devel::REPL
or pdl2
.
For example to see all variables (pdl2
only show piddles):
pdl> help vars
PDL variables in package main::
Name Type Dimension Flow State Mem
----------------------------------------------------------------
no PDL objects in package main::
By the way, does someone know a Devel::REPL
plugin for listing all the variables in use (like y
in the debugger, but only the names, not the values) and then have a x
-like to dump the wanted one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来 Devel::REPL 提供了 直接替代您的第一个问题。在您的主目录中创建一个名为“.perldlrc”的文件,如下所示:
不幸的是,您需要一个逗号,如下所示:
看起来您可以使用相同的控制文件方法来实现其他命令。我没有找到一种方法来消除对逗号的需要,尽管我认为没有任何理由不能使 Devel::REPL 识别和解析这些类型的命令。
It looks like Devel::REPL provides an straightforward alternative for your first question. Create a file called '.perldlrc' in your home directory that looks like:
Unfortunately, you need a comma as in:
It looks like you can implement the other commands with this same control-file approach. I don't see a way to get rid the need for the comma, although I don't think there's any reason Devel::REPL cannot be made to recognize and parse these kinds of commands.
默认情况下,Devel::REPL shell
re.pl
已经转储最后一个表达式的值:The Devel::REPL shell
re.pl
already dumps the value of the last expression by default: