NAME
Devel::Quick - Write single-step debugger one-liners easily (DB::DB)
VERSION
version 0.02
SYNOPSIS
Devel::Trace in one line:
perl -d:Quick='print ">> $filename:$line $code"' prog.pl
The above, with strict checking enabled (not default):
perl -d:Quick=-strict,'print ">> $filename:$line $code"' prog.pl
Or shortened:
perl -d:Quick=-s,'print ">> $filename:$line $code"' prog.pl
If you need '-' as the first character in your code, use a ';':
perl -d:Quick='; -1 * 2;' prog.pl
DESCRIPTION
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 {
my ($package, $filename, $line,
$subroutine, $hasargs, $wantarray,
$evaltext, $is_require, $hints,
$bitmask, $hinthash) = caller(0);
my $args = \@_;
my $code;
{
no strict 'refs';
$code = @{"::_<$filename"}[$line];
}
no strict;
<<CODE>>
}
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;' prog.pl
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
$code
The variable $code contains the line of source code about to be executed. This is provided by @{"_<$filename"}
. See perldebguts for more information.
$args
$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 when the current subroutine sees.
AUTHOR
Matthew Horsfall (alh) - <WolfSage@gmail.com>