Matthew Horsfall (alh)


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


version 0.06


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"'

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;

  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);
        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.

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) - <>