DEV Community

Bob Lied
Bob Lied

Posted on • Updated on

Perl debugger compactDump on by default

TLDR: sub afterinit { push @DB::typeahead, "o compactDump=1" }

When I use the Perl debugger, I usually want the compactDump option turned on. For reasons (?), I have never been able to set this option from the ~/.perldb file. It should be possible to set options by using lines like

...
parse_options("HistSize=100");
parse_options("compactDump=1");
...
Enter fullscreen mode Exit fullscreen mode

but when I try that with compactDump, starting up the debugger gives me a lot of unsightly warnings:

[~/]$ perl -d  -wE 'say "what"'
Variable "$frame" is not imported at (eval 6)[/Users/lied/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/perl5db.pl:7578] line 2.
Variable "$doret" is not imported at (eval 6)[/Users/lied/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/perl5db.pl:7578] line 3.
perldb: couldn't parse ./.perldb: Global symbol "$frame" requires explicit package name (did you forget to declare "my $frame"?) at (eval 6)[/Users/lied/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/perl5db.pl:7578] line 2.
Global symbol "$doret" requires explicit package name (did you forget to declare "my $doret"?) at (eval 6)[/Users/lied/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/perl5db.pl:7578] line 3.
Enter fullscreen mode Exit fullscreen mode

A close reading of some Stack Overflow articles and the perldoc perldebug documentation finally gave me a workaround. The following, added to ~/.perldb, will enable compactDump without the noise:

sub afterinit { push @DB::typeahead, "o compactDump=1" }
Enter fullscreen mode Exit fullscreen mode

This assumes that we are using GNU readline, which, of course we are.

Top comments (0)