in reply to different versions of same Perl module in different Apache vhosts

I have exactly this problem, slightly bigger - currently 46 vhosts running between them 6 different versions of an application - and I've avoided mod_perl for now precisely because of the problem of multiple library versions. I understand that v2 mod_perl does/will fix this problem.

Under v1 it might be possible to work around this problem if each module user knows (or can reach an object that knows) what version of each module it needs. It'd be a bit of a pain, but I can imagine replace each use My::Module; with $application->load_module('My::Module'), and (roughly):

sub Application::load_module { my($self, $class) = @_; return 1 if do { no strict 'refs'; # may need string eq here ${"${class}::VERSION"} == $self->required_version($class); }; (my $path = "$class.pm") =~ s{::}{/}g; delete $INC{$path}; require $path; }

It may also be possible to roll up something similar at a lower conceptual cost using Ingy's only.

Hugo

Replies are listed 'Best First'.
Re^2: different versions of same Perl module in different Apache vhosts
by agaffney (Beadle) on Jun 06, 2004 at 05:16 UTC
    Unfortunately, I need a more transparent solution than either of those. Using 'only' might work if I can put a line in the vhost definition that restricts the version, instead of in the scripts. Is there a way to do that?