perl TemplateToolkit - 无法定位对象方法“new”通过封装

发布于 2024-08-28 08:11:27 字数 593 浏览 5 评论 0原文

我继承了一个基于 Perl 的 Web 项目,并且我正在尝试设置一个本地测试服务器,以便可以在项目内部进行更改。

服务器架构 乌班图9.10 php 5.2.10 mysql 5.1.37 perl 5.10.0-24ubuntu4

所有依赖模块和软件包均已安装,例如 DateTime.pm、TemplateToolkit.pm,但运行应用程序会抛出以下错误消息:

无法通过软件包定位对象方法“new” “模板”(也许您忘记加载“模板”?)位于 ../lib//KPS/TemplateToolkit.pm 第 51 行

这引用的代码块是:

sub new {
    return Template->new(
        INCLUDE_PATH => $KPS::Config::templatepath,
        ABSOLUTE     => 1,
        DEBUG        => 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独孤求败 2024-09-04 08:11:27

您需要首先加载 Template Toolkit,使用:

use Template;

为了确保 Template::Toolkit 正确安装在该系统上,您可以从控制台运行:

perl -MTemplate -e0

如果它返回而没有错误,则意味着 Template.pm wsa 加载成功;如果没有,它会给你一个错误“Can't located Template.pm in @INC...”。

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

提笔落墨 2024-09-04 08:11:27

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

你做了

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

,然后在 b.pm 你做了

package b;

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

package a::b;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文