Martin Wood wrote:
>
> Thanks for the replies so far all - things are already becoming clearer.
>
> > If you add a "standard" module to your set, how will it affect
> > existing apps if they don't directly need it or call it? Why have the
> > "use" statement at all if that particular module is not being used?
>
> So pre-load all modules needed for the site, but still selectively "use" the
> ones needed in each script and pray the list of common modules used doesn't
> change often! Good job we have a Vim macro guru on-site :)
>
> There just seems something inherently bad to me about having a lot of
> duplicate sections of code across 100+ scripts - wouldn't it be easier if
> there was some way all these use module directives could be filtered out
> into one "load common boring stuff" line and not having to worry about
> namespace problems?
>
You could do it with something like this:
for my $package (@PACKAGES) {
for my $module (@MODULES) {
eval "package $package; use $module; 1;";
}
}
This would then load all your default symbols for all modules
into all of your packages. Each Apache::Registry script has
its own package namespace however, so you will still have to
do your uses for the scripts, but if you have decomped most
of your code out of your Registry scripts, so that subs are
in their own packages, then you won't have a problem. So put
your subs in a common package, and then you will only have
one to "use" in each script.
Note that certain web solutions like Apache::ASP compile all
scripts into the same package namespace, so that if you use'd
modules in your global.asa, they would load all the relevant
symbols for all scripts when the global.asa is compiled.
I imagine one day that there might be some Apache::Registry
subclass that might compile all scripts into the same package
too, which you could name, and might help alleviate this problem.
-- Joshua
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051