traveler has asked for the wisdom of the Perl Monks concerning the following question:

I have a Windows/DOS style INI file that I want to process. I decided to use Config::Simple because I have used it before and it is simple :-). The problem is that the file has blank lines e.g.
[foo] Bar=1 Baz= Boo=
The module sets foo.Baz to Boo. I mailed the maintainer, but haven't heard anything. Does anyone know if there is something I can do to read such files?

Thanks, --traveler

Replies are listed 'Best First'.
Re: Blank lines in ini file and Config::Simple
by bschmer (Friar) on Nov 20, 2003 at 22:06 UTC
    Are you using the latest version? I just got version 3.50 and it seems to do the correct thing. The only other suggestion after taking a *real* quick look at the code is make sure that there aren't any spaces at the end of the lines.

    Yep, I tried blank lines, spaces at the end of the lines with no values and things are still humming along as I expect them to.

      I got 4.55 on Monday (three days ago)...
        Perhaps you could post your code? I have 4.55 and things work like I'd expect. Perhaps I'm doing things differently than you are.
Re: Blank lines in ini file and Config::Simple
by PodMaster (Abbot) on Nov 20, 2003 at 21:57 UTC
    ;) If you have wxPerl, Wx::FileConfig will read it just fine ;)

    update: your other options (i'm sure you knew) are Config::IniFiles and Config::IniHash

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Blank lines in ini file and Config::Simple
by traveler (Parson) on Nov 21, 2003 at 14:15 UTC
    At bschmer's request, here is a demo:
    #!/usr/bin/perl -w use Config::Simple; my $cfg = new Config::Simple( "testini.dat" ); die "Config file failure" if not defined $cfg; %config = $cfg->vars(); my $bar = $cfg->param("FOO.Bar"); my $baz = $cfg->param("FOO.Baz"); print "<$bar>, <$baz>\n";
    And the data:
    [FOO] Bar=hello Baz= Boo=
    $bar is printed correctly, but $baz shows up as ARRAY(..).

    --traveler

Re: Blank lines in ini file and Config::Simple
by TStanley (Canon) on Nov 21, 2003 at 13:36 UTC
    I have just made a change to Config::Yacp so that it will handle this problem. The version number is 1.17. I will be posting it later this morning.

    TStanley
    --------
    The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke