【发布时间】:2012-03-05 18:16:05
【问题描述】:
我通过 cpan 安装了 Perl 模块 HTML::Template。 Perl 本身可以识别 Template 模块,但是当我尝试将其用作 Perl CGI 脚本时,它会触发以下错误:
$ cat /var/log/httpd/error_log
[Tue Feb 14 11:28:27 2012] [error] [client 127.0.0.1] Can't locate HTML/Template.pm in @INC (@INC contains: /root/perl5/lib/perjl5/ /usr/local/lib/perl5 /usr/$
[Tue Feb 14 11:28:27 2012] [error] [client 127.0.0.1] BEGIN failed--compilation aborted at /var/www/cgi-bin/index.pl line 4.
[Tue Feb 14 11:28:27 2012] [error] [client 127.0.0.1] Premature end of script headers: index.pl
我的 Perl 脚本(index.pl)如下:
#!/usr/bin/perl -w
use lib "/root/perl5/lib/perjl5"; # is it the correct way to include libs?
use HTML::Template; # error line
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
如果我加载脚本 http://localhost/cgi-bin/index.pl,它会返回 500 内部服务器错误。
模块已安装并位于 /root/perl5/lib/perl5/HTML/Template.pm
事实上,$ perldoc perllocal 返回:
[...]
[1mMon Feb 13 16:43:34 2012: "Module" HTML::Template[0m
· "installed into: /root/perl5/lib/perl5"
· "LINKTYPE: dynamic"
· "VERSION: 2.6"
· "EXE_FILES: "
[...]
它正确安装了吗?
如果我输入$ perl -e "use HTML::Template,则不会返回任何错误
我正在使用 Fedora 16
Linux 版本 3.2.5-3.fc16.i686 (mockbuild@x86-06.phx2.fedoraproject.org) (gcc 版本 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC) ) #1 SMP Thu Feb 9 02:24:08 UTC 2012
【问题讨论】: