You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by si...@siberian.org on 2002/12/11 02:29:44 UTC

Per Vhost @INC

This has come up a few times but I still do not fully 
understand how it works. Here is my situation.

I have a body of software that runs in a specific 
namespace with about 10 libraries. (TourEngine::**). I 
have many versions of this software and will need the 
ability to, on the same server, run multiple instances of 
this software with different versions for a variety of 
reasons.

Using a PerlRequire in the vhost seems to add the @INC for 
the entire vhost population on the server, not just my 
vhost. This results in 'first match wins' behavior since I 
would now have an @INC entry for each TourEngine::** 
directory. I tried Apache::PerlVINC but it wants to reload 
each module on each request and it seems to want to 'own' 
a location space. My modules actually get required as part 
of my HTML::Mason code, they do not handle the entire 
Location.

I tried the PerlFixupHandler and a use libs declaration 
but that just gave me error messages like 'Undefined 
subroutine &lib(use::handler called.' which makes me think 
I have the syntax wrong there and I can not find another 
syntax example.

My preference is not to have to set my @INC in every 
component/lib I call but to have it set in the config 
globally for that Vhost.

So, does anyone have any ideas on how I can load a per 
vhost @INC that doesn't appear to other Vhosts? I want my 
TourEngine::** namespace to be a unique @INC per vhost.

Thanks
John-

Re: Per Vhost @INC

Posted by Kyle Oppenheim <ky...@tellme.com>.
I think you are confusing @INC and %INC.  You should probably read up on the
difference between the two.  The mod_perl guide provides a lot of background
on this issue:
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#use__
__require____do_____INC_and__INC_Explained

In any case, @INC and %INC are only used to load modules.  You can't have
multiple versions of the same package loaded at the same time in a single
interpreter (even outside of mod_perl) since the symbols in the symbol table
can only point to one thing at a time.  Remember that there's only one Perl
interpreter per child process (in Apache/mod_perl 1.x).  If you try to load
the same package again via `require' you'll overwrite the old symbols and,
if you have warnings on, generate a bunch of redefine warnings.

As you discovered, Apache::PerlVINC is just a work-around that reloads every
module (at least those that you say matter) on every request.  That's the
best you can do unless Perl starts supporting some method of side-by-side
versioning of modules.

--
Kyle Oppenheim
Tellme Networks, Inc.
http://www.tellme.com

----- Original Message -----
From: <si...@siberian.org>
To: <mo...@perl.apache.org>
Sent: Tuesday, December 10, 2002 5:29 PM
Subject: Per Vhost @INC


> This has come up a few times but I still do not fully
> understand how it works. Here is my situation.
>
> I have a body of software that runs in a specific
> namespace with about 10 libraries. (TourEngine::**). I
> have many versions of this software and will need the
> ability to, on the same server, run multiple instances of
> this software with different versions for a variety of
> reasons.
>
> Using a PerlRequire in the vhost seems to add the @INC for
> the entire vhost population on the server, not just my
> vhost. This results in 'first match wins' behavior since I
> would now have an @INC entry for each TourEngine::**
> directory. I tried Apache::PerlVINC but it wants to reload
> each module on each request and it seems to want to 'own'
> a location space. My modules actually get required as part
> of my HTML::Mason code, they do not handle the entire
> Location.
>
> I tried the PerlFixupHandler and a use libs declaration
> but that just gave me error messages like 'Undefined
> subroutine &lib(use::handler called.' which makes me think
> I have the syntax wrong there and I can not find another
> syntax example.
>
> My preference is not to have to set my @INC in every
> component/lib I call but to have it set in the config
> globally for that Vhost.
>
> So, does anyone have any ideas on how I can load a per
> vhost @INC that doesn't appear to other Vhosts? I want my
> TourEngine::** namespace to be a unique @INC per vhost.
>
> Thanks
> John-
>