No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I always create a module to handle program configuration, and I always call it Program::RC Then Program::RC has a method new that instantiates an object that reads the configuration from whereever it is stored (config file, à la windows INI file is pretty good, with permissions well set so as to protect sensitive data), database, LDAP directory, whatever. The class offers a series of methods to access the different parts of the configuration file and give the variables values. This approach has one added advantage, each time you instantiate a configuration object, the config file is read, so you can change the configuration and test it on the fly, not even a SIGHUP is needed. An example:
Each time the program has to process a request, it reads its configuration. Unless it's a huge config file, this is almost unnoticeable delay, and you can always memoize or create a cache for this system once it's production time (this is really useful to developing/debugging...) good luck, NB: as I usually use Net::Server to make these things, the fork code can be wrong, please forgive me... -- In reply to Re: Re: How do you load configuration variables
by Excalibor
|
|