Note: this software is frozen. I am unlikely to make changes to it, since I rarely do any new development in Perl now.This is the third release of my Perl5 ConfigFile module. It is basically a bug-fixed version of 1.1. It is written entirely in Perl, and should run on any reasonable flavor of Unix. I would appreciate mail if you cannot get it to work.
I have used this module in a number of applications, including my machine monitoring system, Mom. It has also been put to the singularly strange task of acting as a defintion language for PerlTK GUIs.
Please do contact me with any problems or suggestions you may have.
Here is a larger example of a config file. It's part of my GUI definition module. This file is a header file in the sense that the GUI generation grabs its defaults from here if the user has not overridden them. (Please note the comments at the beginning: this file is just to give an example of larger config files and should not be taken as an esthetic model.) This file is read after one that looks like this, which specifies a little GUI with eight entry spaces, a few buttons, and a message window.
Here are a few more examples:
The module comes with it's own POD documentation.
Or simply download the package.
->get_all was mangling the data
structure. Fixed.
Here is the
comp.lang.perl.modules announcement:
I have decided that my ConfigFile module is suitable for public
consumption. Information on the module can be found at:
http://www.biostat.wisc.edu/~annis/creations/ConfigFile.html
I realize that there are two other modules at CPAN which do similar
things but I found them both over-complex for my purposes. I am,
however, not certain that I should submit this module to CPAN,
since it is, strictly speaking, somewhat redundant. I've checked
out the submission guidelines at CPAN and I'm still feeling
somewhat vague about the whole thing. Any guidance on this question
would be nice.
At any rate, (polite) comments on the module are strongly
appreciated.
This module was written originally for making system adminstration
scripts more flexible on a per-machine basis. I wanted to be able
to specify in a single config file the behavior of a bunch of machines
(NFS is our friend). This led me to the concept of a named property:
NAME machine1
max_users 4
max_load 2
END
I can then use a simple method: $config->get('machine1', 'max_load')
to extract the information I need. If, however, there is information
that is common to most machines, I wanted to be able to specify that,
but be able to overwrite these defaults where appropriate:
DEFAULT normal_machine
max_users 4
max_load 2
END
NAME machine2
DEFAULT normal_machine
max_load 3.5
END
In the above case, ->get('machine2', 'max_load') will be 3.5, but
->get('machine2', 'max_users') will be 4. It is possible from the
perl interface to set it up such that if there is no NAME block
for a given request a global DEFAULT be queried.
As I've used the module more, I've added features (of course). I've
added a basic macro substitution facility, conditional assignment
and multi-line properties. For those applications that don't need
the full blown flexibility (and syntax) of the NAME blocks, I've added
a GLOBAL directive:
GLOBAL
max_users 4
max_load 2
max_opens 64
For GLOBALs (that directive must come after all DEFAULTs and NAMEs),
you can simply use ->get('max_opens').
HTMLized POD documentation is available at the web site.
This module has been used for nearly 5 months in various applications.
I have even put it to the somewhat immoral job of acting as a
GUI definition language for PerlTk.