in reply to Re: Cross-platform config file parsing
in thread Cross-platform config file parsing

Fastolfe - thanks for reminding me of XML::Simple.   Had forgot all about it as an option.   ++ to you and to cianoz for suggesting it.

But... I just can't require my coworkers to learn even simple XML to use the script.   Some are gurus on EIGRP, ATM, etc. but only markup I've seen from any is with Frontpage or MS-Word "save as HTML".   First time someone wrote bad config markup, my code would get blamed 8^(

If I were submitting the code to Freshmeat it'd be a different story.
    cheers,
    Don
    striving for Perl Adept

/me wanders over to Editor Requests to see if Ed will let me add XML::Simple to list in original post...

  • Comment on RE: (2) Cross-platform config file parsing (XML::Simple looks good, but...)

Replies are listed 'Best First'.
RE: RE: (2) Cross-platform config file parsing (XML::Simple looks good, but...)
by Fastolfe (Vicar) on Oct 30, 2000 at 20:23 UTC
    If an 8-year-old can learn HTML, with dozens of different tags and formatting things, surely an adult can learn an XML schema with as many tags as you have configuration options.. *shrug*. I would present them with a sample and see how easily they learn it. Your XML parser should inform them of errors in the XML file as well as early in the process as you can (perhaps a separate process from your application that checks the syntax of the file, which they can run after each change they make).

    In addition, there are lots of simple XML editors on the market now too, complete with nice GUI front-ends, and IE 5 does a pretty good job of displaying it.

    I personally don't think learning XML is going to be your biggest hurdle, but obviously you know the users better than I do, so it's your call... Good luck though.

      Fastolfe - You may very well be right about XML::Simple being a good option for this sit.   Looks otherwise to me, but keeping an open mind, particularly since this is new (Perl) territory for me.   Well, that and the fact that you (and many, many Monks) are better coders than I'll ever be.   {g}

      If there are other hurdles you see, I'd welcome hearing, er, reading them.   No such thing as too well informed.
          cheers,
          Don
          striving for Perl Adept

        If nothing else, just write something simple:
        my %ini; my $group = "global"; while (<DATA>) { chomp; next if /^\s*;/ || !/\S/; # skip comments/blank lines $group = lc($1), next if /^\s*\[([^\]]+)\]/; if (/^\s*(\w+)=/) { $ini{$group}->{lc($1)} = $'; } else { warn "Parse error on line $.: $_\n"; } } print $ini{global}->{this}, "\n"; print $ini{section}->{this}, "\n"; __DATA__ ; sample data, this could be from ; a real .ini file for example.. ; I hope I got the comment delimiter ; right.. maybe it's ' instead.. Some=sample data this=this is an .ini file [Section] THIS=this will be in 'section' (note lower case) instead of 'global'