我正在研究
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";