Ryan Thompson wrote:
> Hi all,
> 
> I did a brief search of the archives, and the web, but found few ideas
> that address this issue... which seems odd, because this is a very
> common problem with typical mod_perl applications.
> 
> What I have is a large distributed mod_perl application, with many
> packages strewn throughout a hierarchy of classes on the filesystem of
> a server. This application code is either replicated to different
> servers, or shared over a read-only NFS partition. Each server needs
> to be able to set a small number of constant global options at compile
> time, which should be stored in a configuration file on the local
> filesystem.
> 
> So, is there an accepted, right way to suck in a local configuration
> file at compile time? And, what's the best way to scope these
> "globals" so that they are visible to the classes and subclasses in
> the system that need to read them? I want to keep coupling to a
> minimum, as there is a lot of reused and reusable code. Again, these
> values can and should be considered immutable during execution.
> 
> RTFM answers gratefully accepted :-)

Not really a mod_perl question, but that's very simple:

MyLocalConfig.pm:
-----------------
use vars qw(%c);
%c = (foo => 1, bar => {});

MyAppConfig.pm:
---------
BEGIN { # you wanted compile time :)
   use vars (%c);
   require MyLocalConfig.pm
   *c  = \%MyLocalConfig::c;
}
now you can access %MyAppConfig::c everywhere in your apps.

This an other techniques are covered here:
http://perl.apache.org/guide/perl.html#Using_Global_Variables_and_Shari

BTW, in perl 'there is no right way', but TIMTOWTDI :)

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/

Reply via email to