santellij has asked for the wisdom of the Perl Monks concerning the following question:

hello,

I'm working with an older mod_perl system. I would like to bring up another virtual host using modified code. The package and routine names will be the same across the two virtual hosts. There are also some global variables floating around in the code (on both sites) as well.

Here's what I have in the http.conf:
RewriteRule ^/Something(.*) /path/to/the/main/code.pl <Directory /path/to/the/main/> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlRequire /path/to/the/main/startup.pl
in the startup.pl I have added:
$Apache::Registry::NameWithVirtualHost = 1;
It looks like not all of the requests are getting prefixed with the virtual host name. I'm having a hard time debugging this but when I force an error (stack trace) I see that some things are listed with the virtual host:
Apache::ROOThost_2ename_2ecom::My::Package::_31_2e0::method::handler
yet others are not:
My::OtherPackage::MyMethod
I can take off all of the virtual hosts from the module names by turning this off:
$Apache::Registry::NameWithVirtualHost = 0;
Any help with this would be great.

thanks.

Replies are listed 'Best First'.
Re: Multiple virtual hosts under mod_perl
by Fletch (Bishop) on Dec 21, 2004 at 16:19 UTC

    I'm 99.2718% sure the only package name munging done is on the ones automagically created by Apache::Registry around the programs it handles. Any modules you require from your code (e.g. CGI or Your::OtherPackage) aren't munged in any way and are shared between everything (that's kinda the whole point of mod_perl keeping the interpreter persistent). If your modules need to keep some server specific state you'll need to do something like passing them $r and keying off that.