【发布时间】:2010-01-13 02:22:38
【问题描述】:
我有以下 perl 代码:
use strict;
use warnings;
use Test::Cmd::Common;
my $path = "/something/not/available";
my $test = Test::Cmd::Common->new(string => 'File system operations');
eval{
$test->unlink("$path");
};
ok(!$@, "file unlike");
print "done.\n";
$test->unlink() 行将失败并抛出异常。但问题是:eval 没有处理该异常,代码执行被中断。
输出:
$ perl test.pl
could not unlink files (/something/not/available): No such file or directory
NO RESULT for test at line 561 of /home/y/lib/perl5/site_perl/5.8/Test/Cmd/Common.pm (Test::Cmd::Common::unlink)
from line 9 of test.pl.
eval 在这里做得对吗?还是我误会了什么?
F。
【问题讨论】: