perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Chamas <>
Subject Re: ASP and @INC
Date Wed, 27 Feb 2002 21:58:25 GMT wrote:
> Hello all
> Further to a message I posted last week about bizarre problems, I've
> corrected most things, partly by correcting the httpd.conf (adding
> <Directory> around <File> settings), etc.
> However I still have problems with Apache::ASP not finding modules -
> sometimes.
> I've figured that my problems occur because:
>  - I use my many of own .pm modules (not a problem in itself, BUT:)
>  - I have those modules in a custom location, NOT the standard perl
> directory and NOT the global.asa directory.

If you do not want to put your modules in Global directory, 
you can add to your httpd.conf:

   use lib qw(/path/to/your/libraries);

When creating portable applications, this one line is usually
what is needed to be tweaked each time you relocate the code
on a file system.  You can break this piece out from the main
httpd.conf by using Apache's Include directive, so that the 
only thing that needs to be tweaked to make the app portable
between servers/workspaces is the one piece of apache include.

.htaccess can also possibly be used in this way, but I tend
to stay away from .htaccess for production apps because of 
the penalty that its use normally incurs.

> In my global.asa I have:
> {
>   push @INC, '/my/custom/dir';
> }

@INC cannot be safely set in global.asa in a permanent way, because
@INC is localized during the execution of ASP scripts.  However, you
could try this too:

# global.asa
my $PERLLIBS = '/path/to/libs';
  -- or --
## set PerlSetVar PERLLIBS in *.conf to make this portable
my $PERLLIBS = Apache->request->dir_config('PERLLIBS');

sub Script_OnStart {
   eval "use lib qw($perl_libs);";

This will force the execution of the use lib command on each
request, which will search @INC, and push the lib path on
if not already there.

> This seemed to work at first but then occaisonally its not reliable and I
> still sometimes get errors "can't find module xxx". I figure its a
> mod_perl thing - or more to the point caused by my lack of understanding
> of mod_perl and apache::asp. (I got it wrong when I thought understanding
> Perl would be enough! )

Its both a mod_perl thing & Apache::ASP... changes to @INC during a request
are usually lost in a mod_perl environment.  Apache::ASP is one step better
by always pushing Global onto @INC for you which is quite handy for loading
web application specific modules.

-- Josh
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA                1-714-625-4051

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message