Dave Rolsky > Devel-StackTrace-1.30 > Devel::StackTrace

Download:
Devel-StackTrace-1.30.tar.gz

Dependencies

Annotate this POD

Related Modules

Data::Dumper
Module::Build
Exception::Class
Devel::Cover
HTML::Mason
XML::Twig
Convert::TNEF
HTML::Template
Net::Syslog
CGI::Carp
more...
By perlmonks.org

CPAN RT

Open  2
View/Report Bugs
Module Version: 1.30   Source   Latest Release: Devel-StackTrace-1.31

NAME ^

Devel::StackTrace - An object representing a stack trace

VERSION ^

version 1.30

SYNOPSIS ^

  use Devel::StackTrace;

  my $trace = Devel::StackTrace->new;

  print $trace->as_string; # like carp

  # from top (most recent) of stack to bottom.
  while (my $frame = $trace->next_frame) {
      print "Has args\n" if $frame->hasargs;
  }

  # from bottom (least recent) of stack to top.
  while (my $frame = $trace->prev_frame) {
      print "Sub: ", $frame->subroutine, "\n";
  }

DESCRIPTION ^

The Devel::StackTrace module contains two classes, Devel::StackTrace and Devel::StackTrace::Frame. The goal of this object is to encapsulate the information that can found through using the caller() function, as well as providing a simple interface to this data.

The Devel::StackTrace object contains a set of Devel::StackTrace::Frame objects, one for each level of the stack. The frames contain all the data available from caller().

This code was created to support my Exception::Class::Base class (part of Exception::Class) but may be useful in other contexts.

'TOP' AND 'BOTTOM' OF THE STACK ^

When describing the methods of the trace object, I use the words 'top' and 'bottom'. In this context, the 'top' frame on the stack is the most recent frame and the 'bottom' is the least recent.

Here's an example:

  foo();  # bottom frame is here

  sub foo {
     bar();
  }

  sub bar {
     Devel::StackTrace->new;  # top frame is here.
  }

Devel::StackTrace METHODS ^

SUPPORT ^

Please submit bugs to the CPAN RT system at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel%3A%3AStackTrace or via email at bug-devel-stacktrace@rt.cpan.org.

AUTHOR ^

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2012 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: