Devel::Backtrace - Object-oriented backtrace
This is version 0.06.
my $backtrace = Devel::Backtrace->new; print $backtrace; # use automatic stringification # See EXAMPLES to see what the output might look like print $backtrace->point(0)->line;
Constructs a new Devel::Backtrace which is filled with all the information caller($i) provides, where $i starts from $start. If no argument is given, $start defaults to 0.
Devel::Backtrace
caller($i)
$i
$start
If $start is 1 (or higher), the backtrace won't contain the information that (and where) Devel::Backtrace::new() was called.
Returns the i'th tracepoint as a Devel::Backtrace::Point object (see its documentation for how to access every bit of information).
Note that the following code snippet will print the information of caller($start+$i):
caller($start+$i)
print Devel::Backtrace->new($start)->point($i)
Returns a list of all tracepoints. In scalar context, the number of tracepoints is returned.
This method deletes all leading tracepoints that contain information about calls within $package. Afterwards the $backtrace will look as though it had been created with a higher value of $start.
$package
$backtrace
If the optional parameter $package is not given, it defaults to the calling package.
The effect is similar to what the Carp module does.
This module ships with an example "skipme.pl" that demonstrates how to use this method.
This method is like skipme except that it deletes calls to the package rather than calls from the package. Usually this means that it deletes exactly one more tracepoint than skipme.
skipme
Before discarding those calls, skipme is called. This is because usually the topmost call in the stack is to Devel::Backtrace->new, which would not be catched by skipmysubs otherwise.
skipmysubs
See also the example "skipme.pl".
Returns a string that contains one line for each tracepoint. It will contain the information from Devel::Backtrace::Point's to_string() method. To get more information, use the to_long_string() method.
Devel::Backtrace::Point
Note that you don't have to call to_string() if you print a Devel::Backtrace object or otherwise treat it as a string, as the stringification operator is overloaded.
See "EXAMPLES".
Returns a very long string that contains several lines for each trace point. The result will contain every available bit of information. See "to_long_string" in Devel::Backtrace::Point for an example of what the result looks like.
A sample stringification might look like this:
Devel::Backtrace::new called from main (foo.pl:10) main::bar called from main (foo.pl:6) main::foo called from main (foo.pl:13)
Devel::StackTrace does mostly the same as this module. I'm afraid I haven't noticed it until I uploaded this module.
Carp::Trace is a simpler module which gives you a backtrace in string form.
Christoph Bussenius <pepe@cpan.org>
If you use this module, I'll be glad if you drop me a note. You should mention this module's name in the subject of your mails, in order to make sure they won't get lost in all the spam.
This module is in the public domain.
To install Devel::Backtrace, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Backtrace
CPAN shell
perl -MCPAN -e shell install Devel::Backtrace
For more information on module installation, please visit the detailed CPAN module installation guide.