perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Drago <>
Subject Re: live and dev versions of a module on the same server
Date Fri, 03 Oct 2008 16:48:38 GMT

--- On Fri, 10/3/08, Phil Carmody <> wrote:

> From: Phil Carmody <>
> Subject: live and dev versions of a module on the same server
> To:
> 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:

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

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

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

  # Delete the entry from %INC:
  delete( $INC{'My/'} );
  # 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/';

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


View raw message