Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Config::Std blank entry in hash, and blank line

by TheDamian (Vicar)
on Dec 14, 2005 at 19:12 UTC ( [id://516734]=note: print w/replies, xml ) Need Help??


in reply to Config::Std blank entry in hash, and blank line

Using the configuration file below I obtain a blank entry when listing all the keys in %config.
That's because every config file starts with the "nameless" section. As soon as you name a section, it shifts to that section instead but, even if your first line is a section marker, there will still be an entry for the nameless section (which had no data) in the resulting hash.

Arguably however, that's unintuitive, and the nameless section ought not appear in the resulting hash unless it has actual contents. I'll patch the next release to work that way.

Also, when adding a new section, a blank line separates the section name from the entry of that section
Yes, that's the standard behaviour. And, no, there's currently no way of altering it. I guess read_config could look at the input file's layout and intuit whether you're separating section markers from config variables. I'll look at adding that behaviour too.

Damian

Replies are listed 'Best First'.
Re^2: Config::Std blank entry in hash, and blank line
by carcassonne (Pilgrim) on Dec 15, 2005 at 13:16 UTC
    I guess read_config could look at the input file's layout and intuit whether you're separating section markers from config variables.

    Maybe just adding a configurable parameter like 'noExtraNewlines' that would put newlines only in-between sections when adding entries ? That is, the current scheme of the user's file use of newlines would be preserved. Only new entries would be adopting the configurable option. Concern is, many users coudl eventually modify the same INI file, each one adding newlines when he/she sees it fit.

    How about then an INI file formatter that would straigthen this out according to a defined (and configurable) scheme ? ;-)

      I would prefer not to add any more configuration parameters. The idea here is simplicity and avoiding too many variations (hence ::Std ;-)

      An INI formatter would be a great idea, but this module isn't (going to be) that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://516734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-03-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found