在不存在的文件上使用带有 -p 或 -n 标志或菱形运算符的 perl 不会因错误而退出:
$ perl -pe '' badfile || echo error
Can't open badfile: No such file or directory.
$
$ perl -ne '' badfile || echo error
Can't open badfile: No such file or directory.
$
$ perl -e 'print while <>' badfile || echo error
Can't open badfile: No such file or directory at -e line 1.
$
当给定错误文件时,如何强制 perl 抛出错误,而不仅仅是警告?