Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Configuration File

by Excalibor (Pilgrim)
on Jul 15, 2003 at 08:40 UTC ( [id://274305]=note: print w/replies, xml ) Need Help??


in reply to Re: Configuration File
in thread Configuration File

Hi there,

I deeply dislike XML for configuration files. Unless your configuration data is extremely complicated, with deeply nested environments, you don't need XML at all; and if so, why are you using such a complex configuration anyway?

A simple win INI style config file is powerful enough to give a lot of structure to a config file, and still easily human readable and editable (see Chris Winters' 'Why I love INI files', his lightning talk this year at YAPC) .

I'm with legLess that YAML is a great option for configuration files.

A different approach that I have successfully used in the past is having a flat key: value(s) file, and provide a module (called Foo::RC.pm) to give it structure by the means of functions (get_router_data(), get_groups_data(), etc...). This has the added advantage of putting all the code (open file, chomp, split, etc...) in one, authoritative place, well documented and maintained, and the ability to merge different configuration files/formats if your system is complex enough that any subsystem just needs a special format for itself. It also makes it more robust before ill-formed config files (all sanity check again performed in just one place) and easily extendable.

As a project meets new requirements during it's development/life time, as it's bound to happen, anyway, your DTD would have to be enhanced to reflect the new functionality, this justs ask for a lot of front-desk thinking about a design you don't yet know. I don't like it at all.

best regards,

--
our $Perl6 is Fantastic;

Replies are listed 'Best First'.
Re: Re: Re: Configuration File
by kral (Monk) on Jul 15, 2003 at 09:41 UTC
    I deeply dislike XML for configuration files. Unless your configuration data is extremely complicated, with deeply nested environments, you don't need XML at all; and if so, why are you using such a complex configuration anyway?

    XML files are complicated if YOU make it complicated. Imho, it's the best way to make a portable config file. Parser for xml exists for almost every language. And it is also much fessibile. Change from a simple configuration to a more complex one is a joke with xml. I can't say the same thing for the ini files.

    ----------
    kral
    (sorry for my english)

      okay, let's compare:

      [user] login: zipi realm: zape [server] ip: 192.168.0.127 port: 11811 # here we allow the whole class C subnet except the gateway auth_ips: 192.168.0.*, -192.168.0.1

      with:

      <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE config-file SYSTEM "" "http://localhost/devel/XML/DTDs/config-file_1_3.dtd"> <config-file> <user> <login value="zipi"/> <realm value="zape"/> </user> <server> <ip value="192.168.0.127"/> <port value="11811"/> <!-- here we allow the whole class C subnet except the gateway --> <auth_ips value="192.168.0.*, -192.168.0.1"/> </server> </config-file>

      And now parse that. I chose a deliberately easy to follow (ficticious) DTD. The first one can be read in every machine where ASCII/ISO-Latin-1 has any meaning (and probable in those with EBCDIC as well, with some care) and processed with a simple while bucle and a split/:/ and a couple of chomps, detecting the [] sections to put the data in the hash correctly. The XML one needs a dedicated parser, and then the user is forced to walk up and down the tree to get the values.

      Now try to edit that by hand. It's easy, right? After all it's just an example. Now let's take something more, mmm, fleshy, like sendmail's config file. Make XML of that and try to understand it! (it's hard enough as it currently is...)

      XML is okay for OpenOffice document processor format, but config files should be parseable with just VI (your system may be down and down to the bare minimum when you have to remotely solve an incidence at 3am). No XML at 3am, please. Actually no XML config.

      Hope I've presented my case more clearly now.... Best regards,

      --
      our $Perl6 is Fantastic;

Re: Re: Re: Configuration File
by Cody Pendant (Prior) on Jul 15, 2003 at 21:50 UTC
    I just want to say, "in my defense" so to speak, that I don't look after any servers and don't use any config files of this type, I was simply pointing out that the specific example documented in the XML::Simple POD was this kind of file, as far as I could see.

    In fact the description of XML::Simple is "Easy API to maintain XML (esp config files)".



    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-19 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found