Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl Sensitive Sunglasses
 
PerlMonks

Blank lines in ini file and Config::Simple

by traveler (Parson)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Nov 20, 2003 at 21:44 UTC ( #308716=perlquestion: print w/ replies, xml ) Need Help??
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

Comment on Blank lines in ini file and Config::Simple
Download Code
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.

[reply]
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.

[reply]
      I got 4.55 on Monday (three days ago)...
[reply]
        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.
[reply]
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
[reply]
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

[reply]
[d/l]
[select]

Back to Seekers of Perl Wisdom


Login:
Password
remember me
What's my password?
Create A New User

Node Status
node history
Node Type: perlquestion [id://308716]
Approved by krujos
help
Community Ads
Chatterbox
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users
Others exploiting the Monastery: (10)
GrandFather
atcroft
herveus
Eyck
biohisham
Haarg
matze77
lamprecht
gnosti
im2
As of 2009-11-21 09:02 GMT
Sections
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth

Future historians will find that the material characteristic of the current era is...

Aluminium
Plastic
Oil
Water
Carbon dioxide
Copper
Iron
Silicon
Salt
Uranium
Hydrogen
Other

Results (729 votes), past polls