Which is where I've run into some problems, how to design it so I can fit in all the info I'm likely to need, and keep it simple? How do other people design their configuration files?
To the specific problem: currently my configuration file just contains a bunch of "XXX=YYY" lines, where the variable names are fairly self explanatory (to users of this program anyway. The script itself is intended to be a shortcut to installing a complex piece of software, which normally requires the installer to edit/apply a bunch of templates to create the configuration. (For example, some variables appear in multiple configuration files for this software, and need to be the same in order for it to function properly, they're usually paths). Anyfish, one of these configuration files contains a variable FTP_INSTANCES which contains a list of numbers, eg: FTP_INSTANCES="01 02 03 04". For each of the numbers contained in this variable, I need to be able to configure a file with the number in its name (in this case, my script should produce the files ftp01.cfg ftp02.cfg ftp03.cfg ftp04.cfg), each containing different information about the ftp server they are supposed to collect files from. So, how do I represent this information in my scripts configuration file, without getting too complex?
I have a feeling I might need to make it like an .ini file:
I don't find it very pretty though, or intuitive (that the user will need to create as many new ftpXX sections as they need for the values in the ftp_instances variable). Also my config file parser will need to be more complex, since currently I'm just splitting on /=/ and that's it.[main] root=/path/to/root filepath=/path/to/files ftp_instances=01 02 03 [ftp01] sourcepath=/source/path/on/server savepath=/save/files/here [ftp02] sourcepath= savepath= [ftp03] sourcepath= savepath=
There appears to be a ton of configuration modules on CPAN, maybe I'm missing a good one, most seem to concentrate on configurations created by, and read by, programs, I'd like one thats easily writeable by humans, and read by programs (with appropriate errors when malformed). Config::General, for example, writes its 'blocks' as xml-like tagged blocks:
Which is/would be a more typing for the user, and thus more to get wrong..<ftp01> sourcepath= savepath= </ftp01>
Any suggestions, clues?
C.
Update:Removed confusing restriction
In reply to Configuration file design by castaway
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |