in reply to RE: RE: (2) Cross-platform config file parsing (XML::Simple looks good, but...)
in thread Cross-platform config file parsing

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

  • Comment on RE: (4) Cross-platform config file parsing (hmmm... other hurdles?)

Replies are listed 'Best First'.
RE: RE: (4) Cross-platform config file parsing (hmmm... other hurdles?)
by Fastolfe (Vicar) on Oct 31, 2000 at 21:48 UTC
    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'