Pinuki, Stas beat me to it (serves me for typing too long of a reply. :-) - the URL he posted has a better explanation than below, but here is a (probably more long winded) description.
The problem with the original script is that the entry that ends up in %INC is the same whether called from script1 or script2, and since calling "use" first checks the %INC, it won't re-load the module (so you get whichever happens to already be loaded for that Apache process.) Another option to what Stas mentioned you could consider is to try removing the use lib lines (or shorten them by one directory if they are actually longer than that) from site1.pl and site2.pl, then call the perl modules like: site1.pl: ... use lib1::Site; ... and site2.pl: ... use lib2::Site; ... You will also have to change the Site.pm files to be: package lib1::Site; and package lib2::Site; In general, you might want to try to move away from this approach anyway, however. I'm guessing the Site.pm files are really configuration files (I had the same problem when I first started working with mod_perl) - if so you may want to think about replacing them. For other options on handling configuration, look at either one of the configuration modules on CPAN (try http://search.cpan.org/search?query=Apache%3A%3AConfig&mode=all), or storing the values inside a configuration file called from Apache startup (this will give you very good flexibility, and since Apache usually starts as root, can increase security too by allowing you to use more restrictive file permissions on your conf files) - information about this is also available from perl.apache.org. On Tue, 2003-02-04 at 20:11, Pinunki wrote: > Hello everyone, > > I am currently running a web server using Perl CGI for > all my web sites and have been attracted to mod_perl > for the performance advantages - particularly not > having to start a new perl interpreter for each > request. I have tried using Apache::Register and > Apache::PerlRun but am having problems due to the fact > that each web site refers to their own copy of my > module called Site.pm (to contain functions, global > variables etc). The problem is that the my scripts get > confused and use variables from the other site's > modules randomly. > > The following example is using Apache::PerlRun (as > it's supposed to be more forgiving that > Apache::Register). I am using Apache 1.3.26 and > mod_perl 1.26 on Debian Woody. > > > .htaccess > --------- > > PerlModule Apache::PerlRun > > <files *.pl> > SetHandler perl-script > PerlHandler Apache::PerlRun > Options +ExecCGI > </files> > > > site1.pl > -------- > > #!/usr/bin/perl > > use strict; > use CGI; > > use lib "lib1"; > use Site; > > my $q = new CGI; > > print $q->header(); > > print <<EOF; > Site 1<br> > VAR: $VAR<br> > EOF > > > lib1/Site.pm > ------------ > > #!/usr/bin/perl -w > > package Site; > require Exporter; > > use strict; > > our $VAR = "Site one"; > > our @ISA = qw(Exporter); > our @EXPORT = qw($VAR); > > 1; > > > site2.pl > -------- > > #!/usr/bin/perl > > use strict; > use CGI; > > use lib "lib2"; > use Site; > > my $q = new CGI; > > print $q->header(); > > print <<EOF; > Site 2<br> > VAR: $VAR<br> > EOF > > > lib2/Site.pm > ------------ > > #!/usr/bin/perl -w > > package Site; > require Exporter; > > use strict; > > our $VAR = "Site two"; > > our @ISA = qw(Exporter); > our @EXPORT = qw($VAR); > > 1; > > > I then call site1.pl and site2.pl multiple times and > get output like this: > > Site 1 > VAR: Site two > > Site 1 > VAR: Site one > > Site 1 > VAR: Site two > > Site 2 > VAR: Site two > > Site 2 > VAR: Site two > > Site 2 > VAR: Site one > > > I can fix this problem by adding the line "PerlSetVar > PerlRunOnce On" to my .htaccess file, but my > performance tests show that this is actually slower > than regular CGI!! > > Is there anything I can do to make this work properly > without renaming all my Site.pm modules (and all > scripts that call them) to have unique names? > > > Thanks, > Pinunki > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com -- Nathan Byrd <[EMAIL PROTECTED]>