"... one thing I failed to highlight is that ###parent config#### and #####child config##### don't actually exist in the file, it's was merely me defining the structure which I forgot to mention"

You actually wrote:

"I have the following text file of configuration details."

It's important to pay attention to details. I can only provide advice on dealing with the input you describe: I can't guess that some of what you provide is correct and other parts are not. Furthermore, the computer can only deal with the input (as you describe it) in your code; for instance, any attempt to match either version of the input with the pattern '#parent config#' would fail.

You may think I'm being pedantic; however, if you look back to the issues I originally raised, you'll see that all six of them are related to a lack of attention to detail.

For your latest version of your input, you can modify my code by changing

$gen = 'child' if /CHILD CONFIG/;

to

$gen = 'child' unless /EQUALS/;

and get the same output values.

-- Ken


In reply to Re^3: Matching String Value with Hash Key by kcott
in thread Matching String Value with Hash Key by Mark.Allan

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.