Esteemed seekers of wisdom,

I find perl hash notation very readable, so I tend to use it for config files, the problem is, that then I have to require/use the file ( which is insecure and unelegant ), and I would prefer to parse it, like you normally do with config files.

With some external lib parsing this hash notation it would be also easy to let non-perl based programs read such files..

First phase would be just parsing something like this:

my $hash={ 'Key1' => "Value1", 'Key2' => "Value2", };

next levels would handle arrays, comments, etc...

What would be the best way to handle this? (ie without evaling this, possibly with some kind of error reporting )

Has anyone else done anything like this, any big hurdles waiting for soul trying that ( I haven't found any module/lib handling this issue )?

UPDATE D'oh! Of course there is, Storable does exactly that.


In reply to Only perl parses perl hash notation? by Eyck

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.