Author image Matthew Horsfall (alh)
and 1 contributors


Devel::Quick - Write single-step debugger one-liners easily (DB::DB)


version 0.08


Devel::Trace in one line:

  perl -d:Quick='print ">> $filename:$line $code"'

The above, with strict checking enabled (not default):

  perl -d:Quick=-strict,'print ">> $filename:$line $code"'

Or shortened:

  perl -d:Quick=-s,'print ">> $filename:$line $code"'

The above, but start stepping immediately (look at code in "use ..." statements)

  perl -d:Quick=-begin,'print ">> $filename:$line $code"'

Or shortened:

  perl -d:Quick=-b,'print ">> $filename:$line $code"'

You can combine opts:

  perl -d:Quick=-s,-b,'print ">> $filename:$line $code"'

If you need '-' as the first character in your code, use a ';':

  perl -d:Quick='; -1 * 2;'


This module allows you to write simple on-the-fly DB::DB line debuggers easily. It injects the following code around the code passed to its import method and eval's it in:

  package DB;

  use strict;
  use warnings;

  $DB::single = 1;

  sub DB {
        # Get who called us
        my ($package, $filename, $line) = caller(0);
        # Get the rest from the context of who called us
        my (undef, undef, undef,
            $subroutine, $hasargs, $wantarray,
            $evaltext, $is_require, $hints,
            $bitmask, $hinthash) = caller(1);
        return if $package && $package eq 'Devel::Quick';

        my $args = \@_;
        my $code;
                no strict 'refs';
                $code = @{"::_<$filename"}[$line];

        no strict;

By default, warnings are enabled but strict mode is disabled. If you want strict, the first argument to import should be -s or -strict.

By default, tracing also starts after compile time. This means that code in use statements will not be seen. If you want to trace into use statements, use the -b or -begin flag.

If you need to pass a - as the first character in the Perl code, you'll need to inject a semi-colon (;) before it like so:

  perl -d:Quick='; -1 * 2;'

Available Arguments

A bunch of varibales are provided by default for ease of use, including all variables returned by "caller" in perlfunc, the source code that's about to be executed, and arguments to a subroutine if the code being executed is from one. All described below.

caller() variables

See "caller" in perlfunc for a description of these.

  • $package

  • $filename

  • $line

  • $subroutine

  • $hasargs

  • $wantarray

  • $evaltext

  • $is_require

  • $hints

  • $bitmask

  • $hinthash


The variable $code contains the line of source code about to be executed. This is provided by @{"_<$filename"}. See perldebguts for more information.


$args is simply a reference to @_ that the code that is about to be executed can see. This is only relevant within subroutines. $hasargs may tell you if this is filled in or not, or just check @$args.

Changing the underlying values will affect what the current subroutine sees.


Matthew Horsfall (alh) - <>