http://qs1969.pair.com?node_id=266914

RollyGuy has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks.

I've been working on a few scripts that have gone beyond simple command-line swtich configuration and have progressed right into needing some sort of configuration file. After having tried severl solutions, I realized that I was unsure of the best (or perhaps my favorite) way of storing program settings.

The three that I have seen/tried have been useful in different ways. The first method is the simple "this=that" in a file that you read in and make your settings. The second method was a perl file that the program simply read in and set up the parameters. The third was actually a configuration file I saw, and it was done in XML. Each of these have their pluses and minuses. I was wondering what people thought about these methods and whether there were ones I was missing out on.

Replies are listed 'Best First'.
Re: Configuration File Style
by defyance (Curate) on Jun 18, 2003 at 17:40 UTC
    Personally, when I need a config file, I stick with the classic this = that using Config::General. One downside of this, however, is nested elements. That can be pulled off a bit easier with an XML style config.

    So, IMO, it depends on your needs :)

    --
    A conclusion is simply the place where someone got tired of thinking.

Re: Configuration File Style
by BazB (Priest) on Jun 18, 2003 at 17:47 UTC

    I'm a fan of just using  do 'config_file';.

    It's easy, doesn't need you to make a decision about which of the Config:: modules to use, and you can make it as simple or as complex as you like.


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Re: Configuration File Style
by valdez (Monsignor) on Jun 18, 2003 at 17:56 UTC

    I don't like ini style, because I usually need deeply nested structure; so my preferred modules are Config::General and XML::Simple. In my opinion, XML::Simple is more versatile than Config::General, but more prone to errors. The best thing would be to have these modules with validation a la AppConfig.

    Ciao, Valerio

Re: Configuration File Style
by particle (Vicar) on Jun 18, 2003 at 18:27 UTC

    i'm a big fan of YAML

    ~Particle *accelerates*

Re: Configuration File Style
by Tomte (Priest) on Jun 18, 2003 at 18:34 UTC

    I like perl-files the best, putting the configuration in a hash and either do or use it.
    It's just the most flexible way of configuring a perl programm, IMHO.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.