如何在 Perl 中获得调用堆栈列表? [英] How can I get a call stack listing in Perl?

查看:44
本文介绍了如何在 Perl 中获得调用堆栈列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以访问(用于打印输出)子 + 模块列表到 Perl 脚本中当前位置之前的任意深度的子调用?

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?

我需要对一些 Perl 模块(.pm 的)进行更改.工作流是从网页通过 cgi 脚本启动的,通过几个模块/对象传递输入,这些模块/对象以我需要使用数据的模块结尾.沿着这条线的某个地方数据发生了变化,我需要找出哪里.

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.

推荐答案

您可以使用 开发::StackTrace.

use Devel::StackTrace;
my $trace = Devel::StackTrace->new;
print $trace->as_string; # like carp

它的行为类似于 Carp's trace,但您可以更好地控制帧.

It behaves like Carp's trace, but you can get more control over the frames.

一个问题是引用是字符串化的,如果引用的值发生变化,您将看不到它.但是,您可以使用 PadWalker 生成一些内容以打印出完整数据(这将是不过很大).

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).

这篇关于如何在 Perl 中获得调用堆栈列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆