在 Perl 的 Template Toolkit 中,我得到两个错误而不是一个。
local $SIG{__DIE__} = \&fatal;
print template('home.htssdfgsml');
sub template {
# --------------------------------------------------------------
#
my ($file, $vars) = @_;
my ($output, $template);
my $config = {
INCLUDE_PATH => $TEMPLATE_PATH
};
$template = Template->new($config);
$template->process($file, $vars, \$output) || die Template->error;
return $output;
}
sub fatal {
# --------------------------------------------------------------
#
my $msg = shift;
print_header();
print "<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font></p><blockquote><pre>$msg</pre></blockquote></font></p>\n";
}
我得到这个输出有两个错误而不是一个:
A fatal error has occured:
file error - home.htssssml: not found
A fatal error has occured:
file error - home.htssssml: not found at /var/path/path/file.pm line
29.
关于如何只打印一个错误的任何建议?