Hey again-

Just wanted to add that I'm aware of the Apache and Apache::Constants
modules, which do provide Apache-specific methods for getting to this
data that work great for mod_perl. My goal with this module was to make
it general enough to be used to parse any Apache-like config file. That
way, if you wanted (a) write a CGI script outside of mod_perl that used
this data, or (b) wrote a custom (maybe non-web) app that used an
Apache-like config file, you could get at the data quickly.

Thanks,
Nate


Nathan Wiger wrote:
> 
> Hi all-
> 
> I've written a module that can parse the Apache httpd.conf config file
> (and in fact any Apache-like config file). It will take a set of
> directive like:
> 
>     ServerName         www.mydomain.com
>     UseCanonicalName   Off
> 
> And parse it case-insensitively, returning a ref to a hash:
> 
>     my $ac = new Apache::Config;
>     my $conf = $ac->readconf($configfile);
>     print $conf->{servername};       # = "www.mydomain.com";
>     print $conf->{usecanonicalname}; # = 0   (not undef so can test
>                                      #        for defined() still)
> 
> I am also finishing up the ability to parse within contexts, such as
> <Directory> and <Location>. I am still unsure of the interface, I have
> two ideas:
> 
>    1. multi-level hash, i.e.
>          $conf->{"directory /"}->{sethandler}
> 
>    3. individual functions, i.e.
>          $conf->directory("/")->{sethandler}
> 
> If anyone has any input, I'm all ears. I like the first one because it's
> really flexible, the problem is that it's difficult to search. The
> second one helps with this issue, but the downside is that new functions
> have to be added if new Apache contexts are defined. It also makes the
> module less flexible as a general config parser, unless you play some
> tricks with the AutoLoader ala Shell.
> 
> In any case, I have several questions:
> 
>    1. Does a module like this exist anywhere?  I saw Doug's
>       Apache::httpd_conf, but this only takes care of writing
>       a very minimal config file. I looked thru all the
>       Apache:: modules but didn't see one.
> 
>    2. Is the name Apache::Config a good name for this module?
>       I also played around with Apache::ReadConf but this
>       prevents me from adding methods that write config files
>       as well (I'd like to provide a writeconf()).
> 
> Thanks as always for your help and input.
> 
> -Nate

Reply via email to