加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在评估之后Perl的$@会不会被定义?

发布时间:2020-12-16 06:19:04 所属栏目:大数据 来源:网络整理
导读:我正在研究 Mastering Perl的 “Error Handling and Reporting”章.在 perlvar的$@条目中,它说: The Perl syntax error message from the last eval() operator. If $@ is the null string,the last eval() parsed and executed correctly (although the op
我正在研究 Mastering Perl的 “Error Handling and Reporting”章.在 perlvar的$@条目中,它说:

The Perl syntax error message from the last eval() operator. If $@ is the null string,the last eval() parsed and executed correctly (although the operations you invoked may have failed in the normal fashion).

现在我想知道eval何时可能无法正确执行,留下带有未定义值的$@.有这种情况吗?

解决方法

这是一种方法(但在你阅读它之前坐下来.;))

$@ = 123;
eval q{
  $@ = 456;
  print ">>>$@<<<n";
  goto SKIP;
};

SKIP:
print ">>>$@<<<n";

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读