3
Perl中的eval
聲明有什麼問題?我試圖檢查XML是通過捕獲從文件的解析拋出與XML::LibXML任何異常有效:Perl中的這個eval語句有什麼問題?
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 [email protected];
有沒有必要單獨申報$樹。 eval的結果是最後評估的結果:my $ tree = eval {...}。 – 2010-01-12 11:26:48