in reply to RE: (4) Cross-platform config file parsing (hmmm... other hurdles?)
in thread Cross-platform config file parsing

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'
  • Comment on RE: RE: (4) Cross-platform config file parsing (hmmm... other hurdles?)
  • Download Code