oldzy — 2010-07-08T02:32:06-04:00 — #1
This is a small part of code from a larger script, but is the main part. I get the same err msg (Can't call method "output" on an undefined value) in a browser and from the shell command line (Can't call method "output" on an undefined value at ./temp.cgi line 11.). I know Text::FastTemplate is working in general b/c it works on all my PHP scripts. Just this one Perl script it does not like for some reason. Running Perl 5.8.8 on centos.
$templatedir = '/home/virtual/site/data/cgi-templates';
$filename = 'customer.tpl.html';
print "Content-type: text/html\
$template = new Text::FastTemplate(file=>$filename, path=>$templatedir);
print $template->output(); [I]<-- the line giving the err msg[/I]
oldzy — 2010-07-08T19:56:39-04:00 — #2
Man, can't believe something so simple took so long to find. It was the actual template files causing the prob. They had an #include to old non-existent template footer file.
oldzy — 2010-07-08T13:59:38-04:00 — #3
This script worked perfectly before changing to a new server.
oldzy — 2010-07-08T12:06:02-04:00 — #4
Tried the example. Exact same err msg.
philiptoop — 2010-07-08T11:57:18-04:00 — #5
Haven't used FastTemplate myself but the documentation says that "path" needs to be an array ref.
This is a list of directories to be searched when a file is specified with a relative pathname. The list of paths is passed in an ARRAY-REF.
$template = new Text::FastTemplate(file=>$filename, path=> [ $templatedir ]);
geniegate — 2010-07-08T10:50:36-04:00 — #6
Text::FastTemplate->new() is returning an undefined value.
Probably due to it not liking something in the constructor, I'd check to make sure the files are readable, and whether it's using some sort of cache directory that isn't accessible? (One would have to inspect Text/FastTemplate.pm, tracing through 'new' to see what it's doing, or, maybe look in the docs for some kind of error variable)
Have a look in $! (not always useful)
lesleyb — 2010-07-12T08:51:01-04:00 — #7
Catching up four days late ....... and only a tip for the future ...
Didn't see any use strict; use warnings; in your code excerpt.
They are both useful when trying to isolate a problem.