Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm trying to use Devel::StackTrace 1.13
I have a module that I want to limit it's scope to reporting just one
I can't even get it to limit according to the docs.
Here is my subroutine that calls it.
sub debug(;$$)
  my ($msg,$level) = @_;                      # the level and message
  return unless $::Debug;                     # if global 0 return
  $level = 1 unless defined $level;           # set default level
  return unless $level <= $::Debug;           # make sure that level
passed in is >= global
  my @ignore_packages = qw  (
  my $trace = Devel::StackTrace->new(ignore_class   =>
                                    ,ignore_package =>
  my $line    = (caller(0))[2];               # get line debug called
  my $caller  = (caller(1))[3];
  print STDOUT ' ' x $level;                  # indent according to
  print STDOUT "$caller from line# $line\n";
  print STDOUT $trace->as_string;             # print stack trace

Sorry I can't send more but it's too much stuff.  The first 2 print
STDOUT are hold overs from the original debug calls.  THen I started
trying to use Devel::StackTrace.  This will trim down once I get the
stack trace to working.

Re: Devel::StackTrace

On 11/16/2006 08:06 AM, bpatton wrote:
Quoted text here. Click to load it

The 'ignore_package' option only recognizes exact package names--not
hierarchies--and that might force you to make the @ignore_packages array
much bigger than you thought. Rather than to print the trace data
directly, you'll have to use s/// to remove the undesired lines first.


use strict;
use warnings;
use Alias;
use Devel::StackTrace;

my $template = '
     my $num = $_[0];
     if ($num > 6) {
         return ::debug();
     } else {
         recurse($num + 1);

package Alpha;
eval "sub recurse { $template }";

package Beta;
eval "sub recurse { $template }";

package Beta::Carotene;
eval "sub recurse { $template }";

package Lambda;
eval "sub recurse { $template }";

package main;

sub debug {
     # Create the new stack tracer.
     my $trace = Devel::StackTrace->new();
     my $str = $trace->as_string();

     # Ignore the entire Beta hierarchy.
     $str =~ s/^Beta::.*$//mg;
     $str =~ s/\n+/\n/sg;
     print $str;



Site Timeline