如何查找“模板进程失败:undef 错误”在 Perl 的模板工具包中?
我已将 Perl CGI 应用程序从一个网络主机移至另一个网络主机。一切都运行良好,除了 Template Tookit 出现以下错误:
“模板进程失败:undef 错误 - 这不应该发生在 /usr/lib/perl5/5.8.8/CGI/Carp.pm 第 314 行。”
这些模板在其他网络主机上运行良好。我在创建模板对象时设置了 DEBUG_ALL 标志,但它不提供有关错误的任何附加信息,只是加载调试输出。
我无法发布模板源,因为其中有很多客户特定的内容。
我写了一个简单的测试模板,效果很好。只是想知道是否有人以前见过这个错误,或者对找到解决方案的最快方法有任何想法。
编辑:这是加载和处理模板的代码片段。
my $vars = {};
$vars->{page_url} = $page_url;
$vars->{info} = $info;
$vars->{is_valid} = 0;
$vars->{invalid_input} = 0;
$vars->{is_warnings} = 0;
$vars->{is_invalid_price} = 0;
$vars->{output_from_proc} = $proc_output;
...
my $file = 'clientTemplate.html';
#create ref to hash
use Template::Constants qw( :debug );
my $template = Template->new(
{
DEBUG => DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_PROVIDER | DEBUG_PLUGINS | DEBUG_FILTERS | DEBUG_PARSER | DEBUG_DIRS,
EVAL_PERL => 1,
INCLUDE_PATH => [
'/home/perlstuff/templates',
],
}
);
$template->process( $file, $vars )
|| die "Template process failed: ", $template->error(), "\n";
I've moved a Perl CGI app from one web host to another. Everything's running fine except for Template Tookit which is giving the following error:
"Template process failed: undef error - This shouldn't happen at /usr/lib/perl5/5.8.8/CGI/Carp.pm line 314."
The templates are working fine on the other web host. I've set the DEBUG_ALL flag when creating the template object, but it doesn't provide any additional info about errors just loads of debug output.
I can't post the template source as there's lots of client specific stuff in it.
I've written a simple test template and that works okay. Just wondering if anyone had seen this error before or has any ideas on the quickest way to find a fix for it.
EDIT: Here's a snippet of the code that loads and processes the template.
my $vars = {};
$vars->{page_url} = $page_url;
$vars->{info} = $info;
$vars->{is_valid} = 0;
$vars->{invalid_input} = 0;
$vars->{is_warnings} = 0;
$vars->{is_invalid_price} = 0;
$vars->{output_from_proc} = $proc_output;
...
my $file = 'clientTemplate.html';
#create ref to hash
use Template::Constants qw( :debug );
my $template = Template->new(
{
DEBUG => DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_PROVIDER | DEBUG_PLUGINS | DEBUG_FILTERS | DEBUG_PARSER | DEBUG_DIRS,
EVAL_PERL => 1,
INCLUDE_PATH => [
'/home/perlstuff/templates',
],
}
);
$template->process( $file, $vars )
|| die "Template process failed: ", $template->error(), "\n";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用 Devel::SimpleTrace 来获取代码位置的堆栈跟踪是当它遇到错误时。也许这会让您更好地了解正在发生的事情。
You might try using Devel::SimpleTrace to get a stack trace of where the code is when it runs into the error. Perhaps that will give you a little better clue as to what is happening.