|more useful options|
Re: Config files in CPAN modules?by blue_cowdawg (Prior)
|on Jul 21, 2006 at 14:51 UTC||Need Help??|
One way I've solved this for some modules for general use that I've authored for my job is to use XML::Simple to store my configs. If I have a program that is invoking a module that needs to get to a config file named "foo.pl" I simply create a file in the directory the script lives in called "foo.xml" and put the configuration information in there. For instance I have some database access modules that I use a lot and I store the information as such:
in my xml file. The module s written to invoke XML::Simple thusly:
This has the added bonus that if I have change any of the parameters that the script and its associated modules need to live on change I don't have to search through all the source code of the modules and script to change variables.
In other cases (and actually, the project I call "disco" is a good example of this) I put a config file that is central for that module. If I ever have to override it I make that a potential parameter for instantiating the module. For instance:
When the module is instantiated it uses a default normally but when the parameter config_file is passed to the constructor I use that value instead.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg