I have many users writing perl data structures to multiple files simultaneously. In file.cfg
{ alpha => { beta => { gamma => theta, delta => lambda, }, beta => { gamma => zeta, }, }, },
If I just `do` this file, it will take only one value for alpha->beta since a Perl hash can have only one unique key. But I want to be able to parse this data structure and indicate that there are duplicate keys in the file. These structures might span multiple files. Is there a way to eval a block at a time from the file - in this example, eval just the first level alpha->beta->gamma->theta - store it in a local hash, and then eventually eval alpha->beta->gamma->zeta and flag it? I know I could have arrays instead and then iterate over them to find copies but I want to keep the intuitive structure intact but still be able to flag any duplicates. Any other thoughts or suggestions of creating files differently are welcome.

In reply to Storing/parsing perl data structure in/from a file by Wilderness

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.