1

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

4

2 回答 2

7

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...".

于 2010-04-12T09:34:17.010 回答
0

还有一件事要检查,因为即使您没有正确设置,接受的答案测试也可能成功;确保模块中的包声明具有正确的路径。场景如下:

你做

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

然后在 b.pm 你做

package b;

你可能会敲打你的头一段时间,直到你意识到你需要做

package a::b;
于 2014-04-22T14:02:52.260 回答