如何在 Perl 中获得回溯?

发布于 2024-08-22 08:49:47 字数 279 浏览 4 评论 0原文

可能的重复:
如何强制堆栈Perl 中所有致命错误的回溯?

我喜欢 Python 的原因之一是,当脚本因错误而退出时,它会输出回溯。我想知道有没有办法让 Perl 也能做到这一点?

Possible Duplicate:
How do I force a stack backtrace for all fatal errors in Perl?

One of the things I like about Python, is that when a script exits because of an error, it spits out a traceback. I'm wondering is there anyway of getting a Perl to do this as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

婴鹅 2024-08-29 08:49:47

将其添加到脚本的顶部:

use Carp 'verbose';
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

它将创建所有致命错误的堆栈跟踪。

Add this to the top of your script:

use Carp 'verbose';
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

It will create a stack trace on all fatal errors.

踏雪无痕 2024-08-29 08:49:47

研究 Carp::Always 模块。

Investigate the Carp::Always module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文