Perl中的这个eval
语句有什么问题?我试图通过使用XML::LibXML捕获从文件解析中抛出的任何异常来检查 XML 是否有效:
use XML::LibXML;
my $parser = XML::LibXML->new(); #creates a new libXML object.
eval {
my $tree = $parser->parse_file($file) # parses the file contents into the new libXML object.
};
warn() if $@;