这个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 $@;