Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: how to require() a file?

0 views
Skip to first unread message

Gunnar Hjalmarsson

unread,
Feb 27, 2009, 4:27:51 PM2/27/09
to beginn...@perl.org
Stanisław T. Findeisen wrote:
> I am trying to require() a file using its absolute name. In command line
> mode everything works fine, but not in Apache:
>
> [Fri Feb 27 17:45:07 2009] [error] Can't locate
> /home/stf/public_html/test/arcv/public_html/../common.pl in @INC (@INC
> contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi

<snip>

> /usr/lib/perl5/5.8.8 . /etc/httpd) at
-----------------------^

> How can I require() a file when using Perl in CGI mode? Do I have to
> modify @INC?

Based on your reply (to an answer that I not saw) it seems like giving
the web server read access to common.pl solved your problem. Together
with the fact that the current directory is included in @INC, it
indicates that you are not running the script under mod_perl.

> I guess I am using mod_perl:

Guess?? You really, really ought to know! What happens if you add this
line to the script:

print "Not mod_perl\n" unless $ENV{MOD_PERL};

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Dermot Paikkos

unread,
Feb 27, 2009, 12:54:04 PM2/27/09
to beginn...@perl.org, sf18...@students.mimuw.edu.pl
> -----Original Message-----
> From: "Stanisław T. Findeisen" [mailto:sf18...@students.mimuw.edu.pl]
> Sent: 27 February 2009 17:03
> To: beginn...@perl.org
> Subject: how to require() a file?
>
> I am trying to require() a file using its absolute name. In command
> line mode everything works fine, but not in Apache:
>
> [Fri Feb 27 17:45:07 2009] [error] Can't locate
> /home/stf/public_html/test/arcv/public_html/../common.pl in @INC (@INC
> contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7
> /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5
> /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
> thread-multi
> /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7
> /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5
> /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi
> /usr/lib/perl5/5.8.8 . /etc/httpd) at
> /home/stf/public_html/test/arcv/public_html/ticket-list.pl line 13,
> <DATA> line 344.\n

>
> How can I require() a file when using Perl in CGI mode? Do I have to
> modify @INC?
>
> I don't really feel like making it a module, and putting it into Some
> Well Known Location is something I don't feel like even more. It's
just
> a supporting file that I want to keep together with the rest of the
> application.

>
> I guess I am using mod_perl:

If you are using mod_perl then you can use the PerlSwitches directive
for -I/path/to/common.pl. Alteratively you use `use lib` in your
ticket-list.pl

HTH,
Dp.


0 new messages