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
!skazat!


In reply to Config File Placement by skazat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.