osdir.com
mailing list archive

Subject: RE: "do" as temp solution for "require" problem ? - msg#00540

List: apache.mod-perl

Date: Prev Next Index Thread: Prev Next Index
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: mail@xxxxxxxxxxxxxxxxxx [mailto:mail@xxxxxxxxxxxxxxxxxx]
Sent: Tuesday, January 28, 2003 11:51 AM
To: modperl@xxxxxxxxxxxxxxx
Cc: stas@xxxxxxxxxx; merlyn@xxxxxxxxxxxxxx; perrin@xxxxxxxx
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
>>>>>> <mail@xxxxxxxxxxxxxxxxxx> 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
> <merlyn@xxxxxxxxxxxxxx> <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!
>




Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Newbie Q on Apache::Include

perl@xxxxxxxxx wrote: My personal web site has both static and dynamic files. The static files have a kind a "look template" maintained by using XSSI. For the dynamic files I wanted to somehow be able to do the same thing using the same files so that I don't need to maintain 2 sets of files. Of the set of scripts there are some that handle forms. I could have the shtml include the script and pass on the query_string. But I want these to be of type POST. So I can't have the form handler to be an shtml file (having the "look") which would call (!--#include ) the cgi script. I need the opposite - parsing of the script output. Then I thought I would check if it was possible with mod_perl and found Apache::Include. This seemed promising to achieve what I would like to do - use the same files (that maintain the look of my web site) for both the static and dynamic pages. You can do this. Technically I think you can POST to a file, but you don't need to. You can do this lots of ways, including post-processing the output of a CGI script with a module like CGI::SSI. What I would suggest is writing a script that you will run under Apache::Registry, and calling Apache::Include->virtual('/uri/of/file') to do the includes. - Perrin

Next Message by Date: click to view message preview

Re: Installation help

Hi there, On Tue, 28 Jan 2003, Blankenship, Scott R wrote: > Basically, I extract mod_perl 1.27, and apache 1.3.1 [snip] > What am I doing wrong? Are you sure you want to use Apache 1.3.1? I'm using 1.3.27 for new builds... 73, Ged.

Previous Message by Thread: click to view message preview

Re: "do" as temp solution for "require" problem ?

mail@xxxxxxxxxxxxxxxxxx wrote: 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. You seem to be talking about including chunks of the page, like server-side includes (SSI). That's not the same as doing a require/use on a module. Modules are for storing chunks of Perl code, not HTML. You originally asked about why your subs from required files were not working. That's what Stas and Randal are telling you: you need to make them into real modules with "package" declarations. There are other ways to do it (like "do") but they are kludges. If you're looking for something to help you manage splitting pages up into chunks of HTML, you should consider either using SSI (<!--#include virtual="/perl/example.cgi?argument=value" -->) or using HTML::Mason, which is based around that idea. - Perrin

Next Message by Thread: click to view message preview

Re: "do" as temp solution for "require" problem ?

>>>>> "Justin" == Justin Luster <justin@xxxxxxxxxxxxxxxxxxxx> writes: Justin> When a Perl script runs under Mod_Perl the current working directory is Justin> no longer the location of the Perl script (I think it is where Justin> Apache.exe is). So when you require an additional file it does not look Justin> in the same directory as your original script for the file. One Justin> alternative that has been mentioned is to place your included file in Justin> one of the locations of the @INC array. Another option that I have used Justin> is to add the path of the original Perl file to the @INC array so that Justin> included files will be looked for there too. But that's not the problem here. See the other postings in this thread. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@xxxxxxxxxxxxxx> <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!
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by