When a Perl script runs under Mod_Perl the current working directory is
no longer the location of the Perl script (I think it is where
Apache.exe is).  So when you require an additional file it does not look
in the same directory as your original script for the file.  One
alternative that has been mentioned is to place your included file in
one of the locations of the @INC array.  Another option that I have used
is to add the path of the original Perl file to the @INC array so that
included files will be looked for there too.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 28, 2003 11:51 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: "do" as temp solution for "require" problem ?

Hi,
Yes, I am using Apache::Registry; how did you know that? ;-)
In fact I am trying to change the CGI-Perl pages of 
http://www.deweertsport.be to mod_perl.
As I was used to work with include files in PHP, I sort continued this 
way of making pages in Perl-CGI.
If you look at the previous mentioned site, you can see there is only 
one file, but it contains a lot of includes.
- a random function for the banners on top
- a file for the navigation on the left which includes a file for the 
date and a file for the counter (mysql database)
- the content pages with different files for the forms redirected per 
OS and type of Browser.
The reason why I work that way is to have a sort of frame in which the 
content is included, directed via the variables of the URL.
That gives me a good overview on how the site is built and it makes it 
easy to maintain.
Now, with mod_per this is a whole different story. Probably I need to 
review my strategy as things get more complicated regarding using 
"use", or "require" ... or "do" ....
Would using Apache::PerlRun be a better option to deal with this way of 
building a website?
Thanks for your advise!
Bart

On Tuesday, January 28, 2003, at 05:21 PM, Randal L. Schwartz wrote:

>>>>>> "mail@adventureforum" == mail@adventureforum net 
>>>>>> <[EMAIL PROTECTED]> writes:
>
> mail@adventureforum> I am using: mod_perl/1.26
>
> mail@adventureforum> Now I tried to include subroutines from an 
> external .pl file with
> mail@adventureforum> "require".
>
> This smells a bit like you're using Apache::Registry (you haven't said
> yet) and you've moved some subroutines into a separate file, but not a
> separate package, and you either aren't aware or don't understand the
> significance of the fact that every Apache::Registry script runs in a
> different package.
>
> Could that be the case?
>
> If you're using Apache::Registry, and you're not properly using
> packages, you'll get burned.  Turn your external code into a real
> module, and things will work again.  Use "use", not "require", not
> "do".
>
> print "Just another (mod) Perl hacker,"
>
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777

> 0095
> <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl 
> training!
>

Reply via email to