-
-
25 Jun 2014 17:19:03 UTC
- Distribution: Devel-Quick
- Module version: 0.08
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (482 / 0 / 0)
- Kwalitee
Bus factor: 1- 92.59% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (11.31KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- none
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Devel::Quick - Write single-step debugger one-liners easily (DB::DB)
VERSION
version 0.08
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
The above, but start stepping immediately (look at code in "use ..." statements)
perl -d:Quick=-begin,'print ">> $filename:$line $code"' prog.pl
Or shortened:
perl -d:Quick=-b,'print ">> $filename:$line $code"' prog.pl
You can combine opts:
perl -d:Quick=-s,-b,'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; $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; <<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
.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;' 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 what the current subroutine sees.
AUTHOR
Matthew Horsfall (alh) - <WolfSage@gmail.com>
Module Install Instructions
To install Devel::Quick, copy and paste the appropriate command in to your terminal.
cpanm Devel::Quick
perl -MCPAN -e shell install Devel::Quick
For more information on module installation, please visit the detailed CPAN module installation guide.