Ok, my last attempt, which involved using <Perl> blocks, didn't work either (and I know why).
Here's the final solution that is working 100% of the time. So... the problem is that 'require' and 'use' want to conditionally not re- import the library based on the module name (which doesn't change)... ...the solution is to not use 'use' or 'require' and instead beat down on the INC hash yourself, and perform a manual 'do' statement. FILE: /foo/htdocs/.htaccess: ================================================== allow from all PerlInitHandler MyAuth::Dispatch PerlSetEnv LIBDIR /foo/lib FILE: /bar/htdocs/.htaccess: ================================================== allow from all PerlInitHandler MyAuth::Dispatch PerlSetEnv LIBDIR /bar/lib FILE: /usr/local/apache2/MyAuth/Dispatch.pm: ================================================== package MyAuth::Dispatch; use strict; use warnings; sub handler() { my ( $req_conn ) = @_; my $LIBDIR = $ENV{LIBDIR} || ""; my $LIBNAME = 'MyAuth/Allow.pm'; $INC{$LIBNAME} = "$LIBDIR/$LIBNAME"; do "$LIBDIR/$LIBNAME"; return &MyAuth::Allow::handler($req_conn); } 1; FILE: /foo/lib/MyAuth/Allow.pm: ================================================== package MyAuth::Allow; use strict; use warnings; use Apache2::Const -compile => qw(OK); sub handler() { my ( $req_conn ) = @_; warn 'foo-version of allow called'; return Apache2::Const::OK; } 1; FILE: /bar/lib/MyAuth/Allow.pm: ================================================== package MyAuth::Allow; use strict; use warnings; use Apache2::Const -compile => qw(OK); sub handler() { my ( $req_conn ) = @_; warn 'bar-version of allow called'; return Apache2::Const::OK; } 1; This allows me to use a different library depending on what directory the user is browsing (coded in the .htaccess file of the directory tree). -- Devin On Tue, 2009-10-20 at 12:07 -0700, Devin Teske wrote: > Yes, but that's a horrible solutions (thinking "utter nightmare" when it > comes to system administration, et. al.). > > > I've currently got it working with this (which seems to be MUCH more > elegant, only requires a single Apache server, no virtual-hosts, is > directory-based, and requires no special configs in httpd.conf -- > just .htaccess files -- given of course that MP2 is loaded): > > <Perl> > my $env = $0; > $env =~ s:^(/usr/env\d+)/.*:$1:; > push @PerlInitHandler, "MyAuth::Dispatch"; > push @PerlSetEnv, [ LIBDIR => "$env/lib" ]; > </Perl> > > > I feel that's a much better solution. Here's Dispatch: > > package MyAuth::Dispatch; > use strict; > use warnings; > sub handler() > { > my ( $r ) = @_; > my $libdir = $ENV{LIBDIR} || ""; > unshift @INC, $libdir if $libdir; > require MyAuth::Authnz; > return &MyAuth::Authnz::handle($r); > } > 1; > > > Now doesn't that work a heck of a lot better? > -- > Devin > > > > > > > > On Tue, 2009-10-20 at 14:32 -0400, Michael Peters wrote: > > On 10/20/2009 01:06 PM, Devin Teske wrote: > > > > > I've been trying for what feels like months now to find some way to have > > > two directories specify the same module name to PerlInitHandler but to > > > use two different modules. > > > > This isn't a limitation of mod_perl but a limitation of Perl. You can't > > have 2 different modules with the same name. This comes up from time to > > time on this list and the best advice usually comes down to this: > > > > Run multiple apaches (on the same machine if you want). Then put a proxy > > in front to redirect to the right one based on the host or path or > > whatever. This is just slightly more complicated to set up, but is the > > most flexible and doesn't require as many resources as it initially appears. > > -- Cheers, Devin Teske -> CONTACT INFORMATION <- Field Engineer FIS - Vicor Business Unit 626-573-6040 Office 510-735-5650 Mobile devin.te...@metavante.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> END TRANSMISSION <-