Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Configuration File Style

by RollyGuy (Chaplain)
on Jun 18, 2003 at 17:30 UTC ( #266914=perlquestion: print w/replies, xml ) Need Help??

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.


    Hlade's Law:

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://266914]
Approved by defyance
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-08-09 02:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found