|No such thing as a small change|
Config::IniFilesby wardk (Deacon)
|on Oct 09, 2000 at 21:38 UTC||Need Help??|
Item Description: A module for reading .ini-style configuration files.
Review Synopsis: I encountered a need for such a tool. Tried it, liked it. Time to share.
Author: Scott Hutton, currently maintained by Rich Bowen
Where is it? http://cpan.perl.org/modules/by-module/Config/RBOW/
Config::IniFiles is a module intended to make life easier for those who rely on flat configuration files. Specifically, files that use the "Windows style" format.
Config::IniFiles offers an easy and reliable method of reading and writing configuration files that utilize the Section key=value format. You can place the entire contents into a multil-dimensional hash, keyed on section, and/or easily pull those sections in their own hash.
I tried this module out as an alternative to what were/are multiple methods of "configuration" being used by my currrent client. Currently, my client's Perl CGI/batch scripts utilize a combination of database, hard-coding and tab-delimited flat files for setting default/site-specific configurations within the applications. Method used seems to depend on the author/maintainer of the day.
My intent was to implement the practice of a single standard method for storing configuration information. Although we develop and run on HP-UX, the development team that is responsible for maintenance and development are more comfortable with Windows and are all familiar with the "Windows style" configuration file format. I am referring to this style as "windows style", if a monk can identify this format properly, I will gladly update my use of this designation!
The style of configuration file is as follows:
I am sure you've been exposed to this formatting. If not, it is pretty self-explanatory.
My goal was to create a file similar to the following which would isolate common variables associated with the "current" environment that the Perl was executing in. In this case, dev/test/prod. The single configuration file would look similar to this (simplified for this example):
The code itself determines which environment it is in based on the hostname
so lets proceed to using Config::IniFiles
While I haven't used all the features of this neat tool, here are a few features that would be real useful if we in fact utilize such a method.
While I have yet to receive authorization to make such changes to my client's applications, I have a good tool for making it happen.
That is all for now...
Note: Updated typo 8/12/02 per demerphq's head up
Note: Updated 9/30/02 - modify <cite> tags to italic since cite wasn't