为什么不死$ template-> error()显示一个行号?

3 perl template-toolkit

在以下简短程序中:

 use Template;
 my $template = Template->new (INCLUDE_PATH => ".");
 $template->process ("non-existent-file")
      or die $template->error ();
Run Code Online (Sandbox Code Playgroud)

为什么不死会产生一个行号和换行符?我的输出如下:

 ~ 502 $ perl template.pl
 file error - non-existent-file: not found ~ 503 $ 
Run Code Online (Sandbox Code Playgroud)

Eri*_*rom 10

Template正在返回类型的错误对象Template::Exception.该对象具有重载的字符串化,该值在打印时应用,但是当die查看该值时,它会看到引用并且不会追加行号和换行符.之前将值强制转换为字符串以解决问题:

use Template;
my $template = Template->new (INCLUDE_PATH => ".");
$template->process ("non-existent-file")
  or die '' . $template->error ();
Run Code Online (Sandbox Code Playgroud)

版画

file error - non-existent-file: not found at scratchpad.pl line 25.
Run Code Online (Sandbox Code Playgroud)