requre,use, modules, namespace...I'm confused...

2001-07-01 Thread swade




Hi,
 I've read the docs on traps in using require and 
use, etc in mod_perl...I'm confused
heres what I'm trying to figure out...

lets say I have 3 sites on 1 box. so I have /home/httpd/site1 
/home/httpd/site2 /home/httpd/site3

each of them host the same scripts. so if my script is test.cgi 
/home/httpd/site1/cgi-bin/test.cgi
/home/httpd/site2/cgi-bin/test.cgi
etc

Now without mod_perl I have a file called configure.cgi in 
/home/httpd/site1/cgi-bin/configure.cgi
etc...for other sites. each configure script is setup differently according 
to the site.


usually I would do, require "configure.cgi" in the test.cgi script; but 
it's my understanding this won't work in mod_perl

what I'm trying to do is figure out how to have test.cgi the same...and 
pull what it needs from the 
configure file. So that when I update test.cgi I can ftp it to all the 
sites without having to change it for
each site. For the life of me I cannot figure out how it's done in mod_perl 
without having namespace problems...

I read that you should use a module, but then I understand you cannot have 
modules with the same name.I readyou could alsogive package 
name in the configure.cgi script..like package config; Will that have the same 
namespace problem? Is there some info on how to do this someone could point me 
to?

thanks,
shawn




RE: requre,use, modules, namespace...I'm confused...

2001-07-01 Thread Wang Xingyu []

 I have same question.And my solution:

1.In httpd.conf
PerlAddVar  conf /home/httpd/site1/cgi-bin/configure.cgi 
PerlAddVar  conf /home/httpd/site2/cgi-bin/configure.cgi
PerlAddVar  conf /home/httpd/site3/cgi-bin/configure.cgi

2.In your test.cgi
 use vars qw(%conf);
 my $site = $ENV{'HTTP_HOST'};
# get site1,site2,etc.
($site) = ($site =~ /^\/(.*?)\.some\.dom\/cgi-bin\/i);
use Apache;
my $r = Apache-request();
my @conf_file = $r-dir_config-get('conf');
foreach (@conf_file)
{
# import all site configuration file
require;
}
no strict qw(refs);
# import configure variable
# call by $conf{'SOME_VAR'};
*conf = \%{${conf::.$site.::conf}};
3.In your site1 configure.cgi,use ref of hash
package conf::site1;
$conf =
{
# web name.
'web_name' = 'site1',
# Parent web link.
'web_link' = 'http://site1.some.dom/',
}
# in different configure.cgi,have different configure variable and
package.


And ,Please referer http://perl.apache.org/guide/,and thanks stas and
other.


-Original Message-
From: swade [mailto:[EMAIL PROTECTED]] 
Sent: 2001Äê7ÔÂ2ÈÕ 13:18
To: [EMAIL PROTECTED]
Subject: requre,use, modules, namespace...I'm confused...


Hi,
 I've read the docs on traps in using require and use, etc in
mod_perl...I'm confused
heres what I'm trying to figure out...

lets say I have 3 sites on 1 box. so I have /home/httpd/site1
/home/httpd/site2 /home/httpd/site3

each of them host the same scripts. so if my script is test.cgi 
/home/httpd/site1/cgi-bin/test.cgi
/home/httpd/site2/cgi-bin/test.cgi
etc

Now without mod_perl I have a file called configure.cgi in 
/home/httpd/site1/cgi-bin/configure.cgi
etc...for other sites. each configure script is setup differently
according to the site.

usually I would do, require configure.cgi in the test.cgi script; but
it's my understanding this won't work in mod_perl

what I'm trying to do is figure out how to have test.cgi the same...and
pull what it needs from the 
configure file. So that when I update test.cgi I can ftp it to all the
sites without having to change it for
each site. For the life of me I cannot figure out how it's done in
mod_perl without having namespace problems...

I read that you should use a module, but then I understand you cannot
have modules with the same name. I read you could also give package name
in the configure.cgi script..like package config; Will that have the
same namespace problem? Is there some info on how to do this someone
could point me to?

thanks,
shawn