Perl cgi @INC different in shell and in http request
- by pistacchio
Hi to all,
I have the follwing, simplest per cgi script:
use strict;
use warnings;
use CGI();
use CGI::Carp qw(fatalsToBrowser);
use Template;
print CGI::header();
foreach(@INC) {
print "$_\n";
}
When called (http://[..]/cgi-bin/p.cgi) I am given the following error:
Can't locate Template.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /home/pistacchio/webapps/htdocs/cgi-bin/p.cgi line 8.
BEGIN failed--compilation aborted at /home/pistacchio/webapps/htdocs/cgi-bin/p.cgi line 8.
I made sure that Template is installed and indeed when running this program from shell it works (loads Template) and outputs:
Content-Type: text/html; charset=ISO-8859-1
/home/pistacchio/lib/perl5
/home/pistacchio/lib/perl5/lib/i386-linux-thread-multi
/home/pistacchio/lib/perl5/lib
/home/pistacchio/lib/perl5/lib/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/5.8.8
Template is installed in /home/pistacchio/lib/perl5/lib/i386-linux-thread-multi
[pistacchio@web118 i386-linux-thread-multi]$ pwd
/home/pistacchio/lib/perl5/lib/i386-linux-thread-multi
[pistacchio@web118 i386-linux-thread-multi]$ ls
auto perllocal.pod Template Template.pm
This directory is correctly listed in env and, as previously posted, in @INC. In @INC it is shown twice, so I even tried to pop it out before calling use Template, but without result. From env:
[pistacchio@web118 i386-linux-thread-multi]$ env
[..]
PERL5LIB=/home/pistacchio/lib/perl5:/home/pistacchio/lib/perl5/lib:/home/pistacchio/lib/perl5/lib/i386-linux-thread-multi
[..]
Removing use Template gets rid of the problem.
Can anybody help?