> P.S. This is also sure to upset the eval haters :)

Trouble is rather that you might end with a bug depending on input if you try increment a hashref.

I would prefer

DB<41> $ref= $tree DB<42> x @keys = split /@/,'a@b@c' 0 'a' 1 'b' 2 'c' DB<43> $ref = ($ref->{$_}//={})for @keys DB<44> x $tree 0 HASH(0xaa630cf0) 'a' => HASH(0xaa6204a0) 'b' => HASH(0xaa6719b0) 'c' => HASH(0xaa75baa0) empty hash DB<45>

Update
And so on for each line
DB<45> x @keys = split /@/,'a@b@d' 0 'a' 1 'b' 2 'd' DB<46> $ref= $tree <= ($ref->{$_}//={})for @keys DB<48> x $tree 0 HASH(0xaa630cf0) 'a' => HASH(0xaa6204a0) 'b' => HASH(0xaa6719b0) 'c' => HASH(0xaa75baa0) empty hash 'd' => HASH(0xaa672e30) empty hash DB<49>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Re^2: creating the hierarchy pattern from the input file by LanX
in thread creating the hierarchy pattern from the input file by pruthvik

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.