First rule for user editable config files, specially if the file needs to be edit often is to be very, very liberal in what you accept. This would rule out XML, Yaml or Perl code solution. It also means that if there are two obvious ways of putting things in the file, you should accept both. And a third way.

Second rule is that it should be simple, which again would rule out XML, Yaml and Perl code.

I might format the config file like this:

root     = /path/to/root
filepath = /path/to/files

server = ftp1
    sourcepath = /source/path/on/server
    savepath   = /save/files/here

server = ftp2
    savepath   = /files/go/here
    sourcepath = /some/path/somewhere
I've been using, and still use, lots of configuration files in different formats (most of them just for personal use). And while I try to make them have more or less the same syntax, I often find that every project benefits from a different syntax.

Some parsers I've used are simply line based, using hardly anything more than split. Sometimes, I write a Parse::RecDescent grammar.


In reply to Re: Configuration file design by Anonymous Monk
in thread Configuration file design by castaway

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.