Perl脚本运行在Linux终端,但在浏览器中的错误
我想在浏览器中运行这个简单的脚本,并保持错误。如果我在linux中运行它,它运行良好。Perl脚本运行在Linux终端,但在浏览器中的错误
脚本 - test.pl:
#!/home/biotools/perl/5.10.0/bin/perl
use lib '/home/biotools/current/lib/site_perl/5.10.0';
use lib '/people/users/123456/classPath/lib';
use IngresLXSetupNoLog;
use strict;
use warnings;
use Path::Class; # this is line 8
my $dir = dir('./mydir'); # foo/bar
print "Content-type: text/html\n\n";
# Iterate over the content of foo/bar
while (my $file = $dir->next) {
# See if it is a directory and skip
next if $file->is_dir();
# Print out the file name and path
print $file->stringify . "\n";
}
错误:
[Tue Nov 29 08:46:29 2011] [error] Can't locate Path/Class.pm in @INC (@INC contains: /people/users/123456/classPath/lib /home/biotools/current/lib/site_perl/5.10.0/x86_64-linux /home/biotools/current/lib/site_perl/5.10.0 /usr/local/biotools/perl/5.10.0/lib/5.10.0/x86_64-linux /usr/local/biotools/perl/5.10.0/lib/5.10.0 /usr/local/biotools/perl/5.10.0/lib/site_perl/5.10.0/x86_64-linux /usr/local/biotools/perl/5.10.0/lib/site_perl/5.10.0 .) at /projects/apps/dev/cgi-bin/miscellaneous/studyinfo/test.pl line 8.
[Tue Nov 29 08:46:29 2011] [error] BEGIN failed--compilation aborted at /projects/apps/dev/cgi-bin/miscellaneous/studyinfo/test.pl line 8.
[Tue Nov 29 08:46:29 2011] [error] Premature end of script headers: test.pl
定义Path::Class
的.pm
文件在哪里? (如果你不知道,尝试添加BEGIN { print "@INC\n"; }
线8之前的权利,并运行在命令行脚本。)
你需要它的父目录添加到您的@INC
,使用其他use lib '...';
编译。
如果我添加了你的代码,它显示.pm位于'/ people/users/123456/classPath/lib /home/biotools/current/lib/site_perl/5.10.0/x86_64-linux/home/biotools/current/lib/site_perl/5.10.0 /usr/local/biotools/perl/5.10.0/lib/5.10.0/x86_64-linux/usr/local/biotools/perl/5.10.0/lib/5.10.0/usr/local/biotools/perl/5.10.0/lib/site_perl/5.10.0/x86_64-linux /usr/local/biotools/perl/5.10.0/lib/site_perl/5.10.0 .' – Catfish
我安装了Path ::使用lib中的类模块/ people/users/123456/classPath';'所以我在'/ people/users/123456/classPath/lib/Path/Class.pm中有Class.pm' – Catfish
@Catfish:To澄清,这是一个目录的列表*,其中*一个*将包含一个包含'Class.pm'的路径目录。奇怪的是,命令行的'@ INC'和浏览器的'@ INC'唯一的区别在于前者具有'/ people/users/123456/classPath/lib',就像'use lib' pragma指定,而后者具有'/ people/users/m089269/classPath/lib'。这有点奇怪。 (如果有的话,我希望在符号链接的情况下会出现相反情况。) – ruakh
当脚本在命令行中运行,@INC
包含其中Path/Class.pm可能发现的路径。这在网络浏览器的情况下显然不是真实的。
请确保您在作为Web服务器运行时熟悉脚本的工作目录和@INC
值,并了解如何根据需要将适当的路径(Path的父级)获取到@INC
。
开始倾销@INC
在这两种情况下,并比较它们,看看可能不存在什么路径。
如果你是一个Debian用户:
$ sudo apt-get install libpath-class-perl
它不会 “在布劳尔” 运行。当从Web服务器运行时,它使用其用户名(如apache)和其权限,而不是你的。 –