If you're not pathologically adverse to a non-CPAN solution:

#! perl -sl use strict; use Data::Dump qw[ pp ]; sub parseConfig { my( $source, %config ) = shift; $source =~ s<(\S+)\s*(\{)\s*(.+)\}|(\S+)(\s+)([^;]+);> < my( $key, $f, $rest ) = ( $1 || $4, $2 || $5, $3 || $6 ); $config{ $key } = $f eq "{" ? parseConfig( $rest ) : $rest; >seg; return \%config; } my $config = parseConfig( do{ local $/; <DATA> } ); pp $config; __DATA__ ## data per your OP

Produces:

C:\test>junk70 { bob => { ed => { larry => { rule5 => { action => "allow", application => "<a href=\"?nod +e=%20any%20\"> any </a>", category => "<a href=\"?nod +e=%20any%20\"> any </a>", destination => "<a href=\"?nod +e=%20any%20\"> any </a>", from => "<a href=\"?nod +e=%20prod-L3%20\"> prod-L3 </a>", "hip-profiles" => "<a href=\"?nod +e=%20any%20\"> any </a>", "log-end" => "yes", "log-setting" => "orion_log", "log-start" => "no", "negate-destination" => "no", "negate-source" => "no", option => { "disable-serv +er-response-inspection" => "no" }, service => "<a href=\"?nod +e=%20any%20\"> any </a>", source => "<a href=\"?nod +e=%20any%20\"> any </a>", "source-user" => "<a href=\"?nod +e=%20any%20\"> any </a>", tag => "<a href=\"?nod +e=%20some_tag%20\"> some_tag </a>", to => "<a href=\"?nod +e=%20corp-L3%20\"> corp-L3 </a>", }, }, }, }, }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Parsing a config file with braces and nested braces by BrowserUk
in thread Parsing a config file with braces and nested braces by IamtheGorf

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.