@Eric OPs, .
, , , perl ( ). . :
use Template;
my $template = Template->new();
$template->process(\"[% 1 / 0 %]")
or die $template->error();
:
undef error - Illegal division by zero at input text line 1.
. perl. :
my $template = Template->new();
$template->process(\"[% 1 / 0 %]")
or die $template->error() . ' ';
:
undef error - Illegal division by zero at input text line 1.
at test.pl line 11.
, perl. . ( , ...)
:
use Template;
my $template = Template->new();
$template->process(\"[% 1 / 0 %]")
or do {
my $error = $template->error . '';
chomp $error;
die $error;
};
:
undef error - Illegal division by zero at input text line 1. at t2.pl line 15.
.. :
sub templateError {
my ($template) = @_;
my $string = $template->error->as_string;
chomp $string;
$string =~ s/(line \d+)\.$/$1/;
return $string;
}
...
use Template;
my $template = Template->new ();
$template->process (\"[% 1 / 0 %]")
or die templateError($template);
, :
undef error - Illegal division by zero at input text line 1 at test.pl line 30.
OP:
file error - non-existent-file: not found at test.pl line 31.