I'm curious why I haven't see the following done, but I assume there is a reason.
Typically when using Carp or Devel::StackTrace, you get output like this:
at trace.pl line 28
main::bar(3, 'ARRAY(0x100ae294)') called at trace.pl line 16
main::foo(3) called at trace.pl line 11
You might very well want to know what's in that array, but you can't see it, even though it's trivial to display that information:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 0; foo(3); sub foo { my $arg = shift; my @array = qw(this that); bar(3, \@array); } sub bar { my ($x, $y) = @_; my $level = 0; while ( my @caller = do { package DB; caller($level++) } ) { my $sub = $caller[3]; my $args = join ", " => map { Dumper($_) } @DB::args; print "$sub( $args )\n"; } }
That prints out:
main::bar(3, ['this','that']) main::foo(3)
It would take a bit of massaging, but one could turn that into some very useful output. Of course, if you're passing around huge data structures or tied variables, there could be problems, but as a development tool, it could be quite useful. Is there a module which already does this? Debug::Trace looks really close, but it appears that you have to specify in advance what you want to trace and I just want to dump a stacktrace.
Cheers,
Ovid
New address of my CGI Course.
In reply to Stacktrace with variables filled in? by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |