我如何忽略 die()
发生在 Perl 中 END
堵塞?
就像现在我得到
END failed--call queue aborted
错误会在调用脚本中冒泡。
最佳答案
将您的端块放在 eval { .... }
内- 这应该可以防止您描述的行为。
#!/usr/bin/perl
print("hi there!\n");
END {
eval{
print("goodbye\n");
die("this can't hurt....");
};
#detect if an error occurred in the eval
if ( $@ ){
print ("an error occurred: $@\n");
}
}
关于perl - 忽略 Perl END block 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14248536/