[英]Why is there a syntax error with this eval?
I'm just trying eval for the first time, and get a compilation error for the following piece of code: 我只是第一次尝试使用eval,并获得以下代码段的编译错误:
my $dom;
eval {
$dom = $PRSR->load_xml(location => $fullpathname, no_blanks => 1);
}
my $dtlDocType = getObjectType($dom); # <----- the error occurs here
It says "Global symbol $dtlDocType requires explicit package name". 它说:“全局符号$ dtlDocType需要显式的程序包名称”。 When I remove the eval and let the line setting $dom stay without a block, it works.
当我删除评估并让行设置$ dom保持无障碍时,它起作用了。 Initializing $dom in the first line to anything doesn't make any difference.
在第一行中将$ dom初始化为任何内容都没有任何区别。
What is the problem? 问题是什么?
eval { ... }
需要使用分号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.