--- On Fri, 10/3/08, Phil Carmody <[EMAIL PROTECTED]> wrote:

> From: Phil Carmody <[EMAIL PROTECTED]>
> Subject: live and dev versions of a module on the same server
> To: modperl@perl.apache.org
> Date: Friday, October 3, 2008, 3:25 AM
> I'm trying to run both the live and dev versions of my
> website using virtual hosting in Apache 1.3, and using
> mod_perl 1.29 (on Debian stable, for reference).
> 
> The problem I'm having is that the package namespaces
> for the two handlers, and every module they require, clash.
> I might need different @INCs too. How have people got around
> this problem in the past?
> 
> Phil
> -- 
> ()  ASCII ribbon campaign      ()    Hopeless ribbon
> campaign
> /\    against HTML mail        /\  against
> gratuitous bloodshed
> 
> [stolen with permission from Daniel B. Cristofani]


There are a few options:

1---
Run your VirtualHost with PerlOptions +Parent.
This gives each VirtualHost its own Perl interpreter.

2---
Run separate instances of Apache for each separate configuration setup you need.

3---
Instead of "use My::ModuleName;" do this:

  # Delete the entry from %INC:
  delete( $INC{'My/ModuleName.pm'} );
  
  # Find and remove the @INC entry where the other module resides:
  my $idx = 0;
  $idx++ until $INC[$idx] eq '/path/to/wrong/lib';
  splice(@INC, $idx, 1);

  # Add the correct path to @INC:
  unshift @INC, '/path/to/correct/lib';

  # Now reload My::ModuleName:
  require 'My/ModuleName.pm';
  My::ModuleName->import();

That should force Perl to actually reload the module.

You could probably streamline this logic a little better as a subref inside of 
@INC.

Best regards,
John Drago



      

Reply via email to