这种结构在 perl 中很常见:
opendir (B,"/somedir") or die "couldn't open dir!";
但这似乎不起作用:
opendir ( B, "/does-not-exist " ) or {
print "sorry, that directory doesn't exist.\n";
print "now I eat fugu.\n";
exit 1;
};
“或”错误处理是否可能有多个命令?
编译上述内容:
# perl -c test.pl
syntax error at test.pl line 5, near "print"
syntax error at test.pl line 7, near "}"
test.pl had compilation errors.