I'm looking for a lightweight config parsing module to use in a mod_perl application. The obvious answer seems to be: just use PerlSetVar directives inside of Apache's own config file(s). However, I'd like to keep configuration information that's not mod_perl specific (for example, things like database connection parameters) out of the Apache config files. I'd like this info to be available to a startup script called from httpd.conf, as well as available outside of Directory or Location sections, but PerlSetVar info is normally only accessible inside a request (I think). Also, I'd ideally like to be able to update my config files and have them reparsed without having to restart Apache.

First of all, feel free to tell me that the above approach is a bad one and that I should stick with Apache's own config parsing features. But, if not, read on ...

I have some hand-rolled code that I'm using at the moment. It involves a globally available tied hash that caches the config parameters, then stats the config file each time a parameter is fetched. If the config file's modification time has changed, it reparses the file; otherwise it uses the cache. However, I'd prefer to use a module from CPAN for all the usual reasons. I've browsed through CPAN, as well as Super Searched here on perlmonks, and there are plenty of modules that will do the config parsing with no problems. However, since I haven't used any of these modules in a production environment, here's what I'm ultimately looking for in a module:

  1. It parses standard types of config files. (OK, this is obvious, but I thought I'd restate it.)
  2. It reparses config files if they have changed. Otherwise, the config info should stay cached.
  3. It has a small memory footprint. Since this is running under mod_perl, it will stay in memory for the life of the process.

It would be nice to use AppConfig, since I'm already using Template Toolkit, meaning that AppConfig is already installed. However, I'm not familiar with it enough to know about its memory requirements and ability to reparse changed files. Again, there are plenty of others which meet the first requirement, but I'm not sure about the other two.

Any suggestions?

-jehuni


In reply to Config parsing module for mod_perl app? by jehuni

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.