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.
How would I accomplish this?
See the documentation for < [command]
in perldebug:
< [ command ]
Set an action (Perl command) to happen before every debugger prompt.
x
is not a Perl command. You want { [command]
:
{ [ command ]
Set an action (debugger command) to happen before every debugger prompt.
For example:
$ 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'
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With