[Chicago-talk] Config file parsers
Michael Graham
magog at the-wire.com
Wed May 11 10:33:26 PDT 2005
> There are about a 1000 config file parsers on cpan. Can anyone
> recommend one that:
>
> 1) uses few (or no) prerequisite modules
> 2) in heavy use and is maintained.
>
> Any suggestions on the format I should be heading toward (ini, apache,
> xml, yaml...)?
I'm a fan of Config::General (Apache-style configs). It allows
multi-level configurations, and has a comfortable syntax. No
prerequisites.
I like Apache-style configs because they scale well. You can start with a
simple config with just keys and values:
title = ACME Widgets Inc
navbar = user
But when your configuration needs grow you can move these into sections:
<admin>
title = ACME Widgets Inc - Administration
navbar = admin
</admin>
<user>
title = ACME Widgets Inc
navbar = user
</user>
And then, one day if you need to go more than one level deep, you can:
<admin>
title = ACME Widgets Inc - Administration
navbar = admin
db_connect_string = dbi:Pg:dbname=example
db_username = admin
db_password = seekrit
<db_options>
RaiseError = 1
AutoCommit = 1
</db_options>
</admin>
If you start off with INI files, you're stuck with two levels :)
Config::Scoped is also nice. It has more prerequisite modules though.
Michael
-----------------------------------------------------------------------
Michael Graham <magog at the-wire.com>
YAPC::NA 2005 Toronto - http://www.yapc.org/America/ - na-help at yapc.org
-----------------------------------------------------------------------
More information about the Chicago-talk
mailing list