NAME
Devel::Trace::More - Like Devel::Trace but with more control
VERSION
Version 0.05
SYNOPSIS
#!/usr/bin/perl -d:Trace::More
use Devel::Trace::More qw{ filter_on };
filter_on('blah');
filter_on(qr/blah/);
filter_on(sub { my ($p, $file, $line, $code) = @_; ... });
# or
$IS_INTERESTING = sub { my ($p, $file, $line, $code) = @_; ... };
DESCRIPTION
This module will print out every line of code as it executes when used under the perl debugger. By default all executed lines will print to STDERR. By calling filter_on with a code ref, regex ref, a scalar, or by setting $Devel::Trace::More::IS_INTERESTING directly then only those lines that are 'interesting' will be returned.
If filter_on is given a scalar or a regular expression reference then the file name of the code being executed or the line of code itself that matches the given patter will be printed. Passing in a code ref is the same as setting $IS_INTERESTING itself. Setting the filter this way will allow you to do more complicated things like filtering on just the module name or the line number of the code. $IS_INTERESTING can be changed in different places in the code if needed.
Caveat: Using regular expressions to filter what gets printed can cause unexected issues if the code being debugged relies on the regular expression global variables. Use with caution!
FUNCTIONS
filter_on(...)
Takes a string, code ref, or regular expression ref and sets the IS_INTERESTING code ref appropriately.
- String
-
A string will cause the line of code to be printed if either the filename or the code line has the string in it.
- Code Ref
-
A code ref passed will just set $IS_INTERESTING to it, saves a few characters of typing.
- RegEx Ref
-
The line of code will be printed if the regular expression matches either the file name or the line of code
trace('on') or trace('off')
Turns the printing of code on or off
output_to($filename)
Given a filename the code lines will get printed to the file instead of STDERR. Can be called with different filenames at different points in the script if need be. By default the file will be open for reading and will be either created or cleared. You can input '>>' as a param to have the trace keep appending.
SEE ALSO
AUTHOR
mburns, <mburns.lungching@gmail.com>
Also code from Mark Jason Dominus
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Mike Burns
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.