my $blurb =<<'END_BLURB';
He looked up. "Time is never on our side, my child. Do you see the irony? All they know is change. Change is the constant on which they all can agree.
Whereas we, born out of time to remain perfect and perfectly self-aware, can only suffer change if we pursue it. It is against our nature.
We rebel against that change. Shall we consider them greater for it?"
END_BLURB
Perl 5 中读取文件最清晰的方式是:
use autodie;
open my $fh, '<', $filename;
while (my $line = <$fh>)
{
chomp $line;
...
}
,$@ 是一个 全局 变量。为了安全起见,你应该在意图捕获异常之前,用 local 本地化的它
的值:
local $@;
# 也许无法打开日志文件
my $fh = eval { open_log_file( 'monkeytown.log' ) };
# 捕获异常
if ($@) { ... }