views:

82

answers:

1

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";
+4  A: 

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.

Brian Phillips
Thanks Brian, I'll give that a go.
swisstony
That did the trick. The stack trace showed the problem was with Text::Wrap::wrap called from the Template::Plugin::Wrap. I removed the plugin (which I can manage without) and it all started working. I'd never heard of Devel::SimpleTrace thanks for telling me about it.
swisstony