Hi, I'm trying to get a config file, change to a structure having id,parent,key,value (see example below), so then I can create sql commands to insert into an oracle table.

Example of config:

# This is a comment feed_realtime_processor_pool = ( 11, 12 ) ; dropout_detection_time_start = "17:00"; # Sometimes the config can have sub-structures named_clients = ( { name = "thread1"; user_threads = ( { name = "realtime1"; cpu = 11; } # more comments { name = "realtime2"; cpu = 12; } # more comments ); } );
(...) Converting:
id,parent, key, value 01,null, 'feed_realtime_processor_pool', '11' 02,null, 'feed_realtime_processor_pool', '12' 03,null, 'dropout_detection_time_start', '17:00' 04,null, 'named_clients', null 05,04, 'name', 'thread1' 06,04, 'user_threads', null 07,06, 'name', 'realtime1' 08,06, 'cpu', '11' 09,06, 'name', 'realtime2' 10,06, 'cpu', '12'
So, the question is:

1. Somebody knows some lib/module that can do this? I couldn't find.

2. If not, somebody can give me some suggestion about how should I start this script, maybe using different modules to help me parsing the config? To clean and parse the config is the harderst part for me.

Thanks.

In reply to Config file to tree format with id, parent, key, value by arthur_accioly

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.