Perl,如何打印包名?
在 Perl 中是否可以访问当前包的名称(例如,在自定义错误报告中打印它)?
Is it possible - in Perl - to access the name of the current package (for example, to print it in a customized error report) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 perldoc perlmod:
From perldoc perlmod:
__PACKAGE__
将获取编译代码的包。或者,您可能需要
调用者
。它获取调用当前子程序的代码的包。__PACKAGE__
will get you the package in which the code was compiled.Alternatively, you might want
caller
. It gets the package of the code that called the current sub.