Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Config Files in Perl

by traveler (Parson)
on Nov 22, 2006 at 22:18 UTC ( #585628=note: print w/replies, xml ) Need Help??


in reply to Config Files in Perl

Some thoughts:
  • #1 only allows single options e.g name=value. You could use Config::INI::Simple or something similar
  • numbers 2 and 3 can be very dangerous if you make mistakes in them or if people who edit them try to do "bad things"
  • I prefer using XML-based config files and using, say, XML::Simple to parse the file. It is just about as easy as parsing name=value files.
  • You could use Config::General or Config::Generic for more complex configurations, but why not just go with XML?

Replies are listed 'Best First'.
Re^2: Config Files in Perl
by blazar (Canon) on Nov 22, 2006 at 22:34 UTC
    I prefer using XML-based config files and using, say, XML::Simple to parse the file. It is just about as easy as parsing name=value files.

    I sort-of second that, except that I'd use YAML. Even if one doesn't know it (I don't really), it should be easy enough to look at some samples and imitate them, or instruct one about how to do so in a few words. It's more human readable and writable IMHO.

      I agree, YAML is great. Loading and saving a config is dead easy, and the config is very human read/writable.
Re^2: Config Files in Perl
by chromatic (Archbishop) on Nov 22, 2006 at 22:26 UTC
    ... why not just go with XML?

    Because humans might have to modify the configuration file?

      They might. OTOH it might all be done by software. That wasn't specified.

      Now, I agree that XML is not beautiful, but so many people who might edit config files probably are at least somwehat used to HTML, and even vim knows XML highlighting. I do not think it is a problem unless the config file designer goes wild...

        You should be programming away from bad/worst case scenario not around assumptions about the end-user.

        XML sure is terse and unweildy, no matter whether a human is used to it or not, the chances of things going wrong as a result of a "configuration error" when manually editing XML are high.

        However, in the day and age of RAD, it's wise and definitely feasible to have a UI manage and maintain the configuration file(s), XML or otherwise.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://585628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2021-10-22 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?