Simple config for the perl debugger

[Originally posted on]

I’ve been using a config file ($HOME/.perldb) for some time now. While it’s not the biggest file in the world, it automates settings that I’m far too lazy to type every time I fire the beast up.


$DB::deep=1000 ;
sub afterinit { push @DB::typeahead, "{{v" unless $DB::already_curly_curly_v++; } ;
parse_options('dumpDepth=2 NonStop=1') ;

The Explanation


This increases the limit for the recursion limit from 100 – a level that’s so low I seemed to be hitting it all the time – to 1,000.

sub afterinit { … }

I like ‘v‘ as a way of seeing where I am in the code, with some context. I hate typing it myself every time the debugger returns to the prompt.

This small piece of voodoo simply pushes the command ‘{{v‘ onto the list of things to do when the debugger has finished initialising. ‘{{‘ is “Add to the list of debugger commands to run before each prompt” and ‘v‘ is “View window around line”.

Until recently the command was just

sub afterinit { push @DB::typeahead, "{{v" } ;

This was annoying if you used ‘R‘ to restart the script you were debugging as you’d call ‘{{v‘ again and force an extra ‘v‘ at every prompt. This would increase every time you used ‘R‘.

The variable is forced into the DB:: namespace, otherwise you’d increment a value scoped to the afterinit() sub.

parse_options(‘dumpDepth=2 NonStop=1’)

Set a couple of useful options:

  • dumpDepth=2 limits the depth of variables shown if you use ‘x‘ or similar on a variable. Especially useful if you’re forever accidentally examining DBIx::Class objects.
  • NonStop=1 saves you from having to type ‘c’ after everything has initialised so that your program will run. Useful if you drop in $DB::single = 1 statements as your initial breakpoint in the source.
Print Friendly
This entry was posted in Perl and tagged , , , , by Chisel. Bookmark the permalink.

About Chisel

I've been interested in technology since my childhood (my Acorn Electron era). Commercially I've worked with C and VBA (Access) [but we don't talk about that]. In 2000 I secured my first role as a Perl Programmer and that's been my primary language since then. I dabble in bash, puppet, and a few other skills that help me dip my toe in the DevOps water, or provide a conduit beween the dev and ops worlds. I joined Net-A-Porter in November 2006 and have been happily evolving with the business since then.

One thought on “Simple config for the perl debugger

Leave a Reply