Is there a way I can access (for printout) a list of sub + module to arbitrary depth of sub-calls preceding a current position in a Perl script?
I need to make changes to some Perl modules (.pm's). The workflow is initiated from a web-page thru a cgi-script, passing input through several modules/objects ending in the module where I need to use the data. Somewhere along the line the data got changed and I need to find out where.
a call stack is a stack data structure that stores information about the active subroutines of a computer program. A stack trace is a report of the active stack frames at a certain point in time during the execution of a program.
The carp function in Perl is the basic equivalent of warn and prints the message to STDERR without actually exiting the script and printing the script name.
In a list context, with no arguments specified, caller returns the package name, file name and line within the file for the caller of the current subroutine. If EXPR is specified, caller returns extended information for the caller EXPR steps up.
You can use Devel::StackTrace.
use Devel::StackTrace; my $trace = Devel::StackTrace->new; print $trace->as_string; # like carp
It behaves like Carp's trace, but you can get more control over the frames.
The one problem is that references are stringified and if a referenced value changes, you won't see it. However, you could whip up some stuff with PadWalker to print out the full data (it would be huge, though).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With