I like Config::Properties which is very similar to the java.util.Properties class. It allows for reading/writing of a file with the folowing formats:

# This will get ignored ! This will also get ignored variable1: /somedirectory variable2: /someotherdirectory variable3 = /yetanotherdirectory variable4: This is a longer than usual \ property value

It ignores blank lines and comments, can recognize = or : as a separator, and can deal with multiline properties. It's pretty easy to use, and handles most simple situations well. This would likely be my first choice.

XML is generally not my first choice for config files, but usually the next step once they start to become less simple and my configuration file needs to be able to cope with a complex configuration where a tree might be useful. XML files are easy for a user who is hand-editing to mess up. I'll second GrandFather's recommendation of XML::Simple but only for those cases that I can't address with a simpler solution.

Many of the other configuration file suggestions that I've seen mentioned I might use if I had no control of the configuration file format that I was reading: Unix passwd file formats, Win32 ini files, etc.


Updated: Huh.. Somehow, I missed AppConfig. Nice one, davidrw - I like it. I think between Config::Properties, AppConfig, and XML-Simple those would cover any of my needs

In reply to Re: Config file by rcseege
in thread Config file by cajun

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.