[英]Perl script runs in linux terminal, but errors in browser
我正在尝试在浏览器中运行此简单脚本,并且不断出错。 如果我在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
当在命令行中运行脚本时, @INC
包含可能在其中找到Path / Class.pm的路径。 在Web浏览器中显然不是这样。
确保在作为Web服务器运行时对脚本的工作目录和@INC
值有很好的了解,并弄清楚如何在需要时将适当的路径(Path的父路径)放入@INC
。
首先在两种情况下都转储@INC
并进行比较,以查看可能不存在什么路径。
定义Path::Class
的.pm
文件在哪里? (如果您不知道,请尝试在第8行之前添加BEGIN { print "@INC\\n"; }
,然后从命令行运行脚本。)
您需要使用另一个use lib '...';
将其父目录添加到@INC
use lib '...';
附注。
如果您是debian用户:
$ sudo apt-get install libpath-class-perl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.