Welcome to the Monastery | |
PerlMonks |
Config File Placementby skazat (Chaplain) |
on Apr 29, 2002 at 02:17 UTC ( [id://162742]=perlquestion: print w/replies, xml ) | Need Help?? |
skazat has asked for the wisdom of the Perl Monks concerning the following question: Hello all, I have an interesting scenario, I have a group of programs that reads in a config file. These programs can all be called differently; some are cgi scripts, some are executed when a email is piped to them, some are called via a cron job. The config file itself is read in by a module, we'll say ProgConfig.pm On top of scripts that use ProgConfig.pm are two lines similar to this: use lib '/home/account/privateperllib/'; use ProgConfig.pm; ProgConfig.pm holds defaults that can be changed via the config file it reads, which, at the moment, is just evaled in. This allows easy updating of the program's libraries, without having to tweak the ProgConfig module itself. The problem is, depending on what enviroment ProgConfig is called from, finding the config file can be a bit difficult. some my question is, what would be a good place to put a config file that the ProgConfig module can always find? I was thinking, (duh) the home directory of the user would bea good spot to put the config file. This is usually held in $ENV{HOME} but! this Env variable sometimes isn't available to cgi scripts. The closest variable I can find is $ENV{DOCUMENT_ROOT} which, isn't the home dir, it's usually the public html dir. I could probably munge the $ENV{DOCUMENT_ROOT} variable and whack off the last directory and say 'this is the home directoy' but that doesn't seem like the best idea. Has anyone solved something similar to this? -justin simoni
Back to
Seekers of Perl Wisdom
|
|