为什么“$@”不可信?
我似乎记得在 eval
之后信任 $@
的值是不安全的。关于信号处理程序有机会在您看到它或其他东西之前设置 $@
的事情。我现在也太累太懒了,无法追查真正的原因。那么,为什么信任 $@
不安全呢?
I seem to recall that it is not safe to trust the value of $@
after an eval
. Something about a signal handler having a chance to set $@
before you see it or something. I am also too tired and lazy right now to track down the real reason. So, why is it not safe to trust $@
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Try::Tiny
perldoc 有关于$@
问题的明确讨论:The
Try::Tiny
perldoc has the definitive discussion of the trouble with$@
:Try::Tiny 文档 有一个非常好的
列表eval
/$@
缺点。我想你可能指的是 本地化 $@ 默默地掩盖错误< /a> 部分在那里。The Try::Tiny docs have a pretty good list of
eval
/$@
shortcomings. I think you might be refering to the Localizing $@ silently masks errors section in there.$@
与每个全局变量都有同样的问题:当其他东西设置它时,它会在整个程序中重置。任何eval
都可能设置$@
。即使您在附近没有看到eval
,您也不知道还有谁可能调用它(子例程、绑定变量等)。$@
has the same problems that every global variable has: when something else sets it, it's reset across the entire program. Anyeval
might set$@
. Even if you don't see aneval
nearby, you don't know who else might call one (subroutines, tied variables, and so on).