0
votes

I have inherited a web project that is perl based and I'm attempting to set up a local testing server so changes can be made internally to the project.

The server architecture Ubuntu 9.10 php 5.2.10 mysql 5.1.37 perl 5.10.0-24ubuntu4

All the dependent modules and packages are installed such as DateTime.pm, TemplateToolkit.pm but running the application throws the following error message:

Can't locate object method "new" via package "Template" (perhaps you forgot to load "Template"?) at ../lib//KPS/TemplateToolkit.pm line 51

The code block that this refers to is:

sub new {
    return Template->new(
        INCLUDE_PATH => $KPS::Config::templatepath,
        ABSOLUTE     => 1,
        DEBUG        => 1,
    );
}

If anybody is able to shed any light on this or point me in the right direction it would be greatly appreciated.

Thanks

Simnom

2

2 Answers

7
votes

You need to load Template Toolkit first, with:

use Template;

To make sure that Template::Toolkit is properly installed on this system, from a console you could run:

perl -MTemplate -e0

If it returns without an error, it means Template.pm wsa loaded succesfully; if not, it will give you an error of "Can't locate Template.pm in @INC...".

0
votes

An additional thing to check because the accepted answer test could be successful even if you are not setup correctly; make sure that the package declaration in the module has the correct path. The scenario is as follows:

You do

use a::b;
...
a::b->new();

and then in b.pm you do

package b;

You may be banging your head for a while until you realize that you need to do

package a::b;