In a recent post, I asked if it was possible to parse out sections of a simple Makefile, and I stumbled upon Config::General, which seems to do the trick perfectly...

Or so I thought.

I found an edge condition that seems to be cropping up more and more in the Makefile targets I'm preprocessing, that breaks the standard parsing behavior of this module.

Further reading of the pod indicates that this module allows me to subclass the split operations, using -SplitPolicy and -SplitDelimiter. I've tried various incantations, but I can't seem to find the right magical mojo to make it do what I need.

So I'm here, asking if there are any other monks (or modules) that might be able to help me here. Here's some code that exhibits the problem:

# This is my sample config file TEMPLATE_FOO = 1 TEMPLATE_BAR = two OPTION_THREE = baz THIS_BREAKS = \ MULTILINE = \ Foo \ Bar \ Baz

And the perl that processes this:

use strict; use warnings; use Data::Dump qw(dump ddx); use Config::General; my $conf = Config::General->new(-ConfigFile => "sample.conf"); my %prev_config = $conf->getall; print dump(\%prev_config);

When I process this using the code above, I get the following result:

{ OPTION_THREE => "baz", TEMPLATE_BAR => "two", TEMPLATE_FOO => 1, THIS_BREAKS => "MULTILINE\t= Foo\tBar\tBaz", }

Note how THIS_BREAKS sucks the next lines up into its value container? That shouldn't happen, especially with the additional line break after the multi-line continuation.

I tried using -SplitDelimiter to compensate for this with some basic and complex regular expressions, without much success.

I looked into Config::General::Extended and it seems to have a bit more granular control over the hash keys and values, but I'd rather not do that kind of autopsy on the module's classes if I don't have to.

Is there another way to do this? Thanks in advance, my fellow brethren.


In reply to An odd Config::General parsing problem by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.