Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Perl to the rescue!   Read up on the topic of auto-vivification, which is a fancy-pants way of saying that something “just springs to life automatically.”   Hash structures of fairly arbitrary complexity can be fairly instantly built that way.

For example, consider:

Without you doing anything out-of-the-way at all, $foo will become a hashref and, just like that, it will have a key 1 which contains a hashref with a key a ... and so on ... and at the tail of the thing will be the number 1, filed under foobar, because that key sprang into existence with the value zero (which is what it needs to be because it’s about to be incremented), which got incremented by the ++ operator.   If you execute the statement again, well, the entire data structure already exists, and now the value at the tail of it is 2.

If that ain’t magic, I don’t know what is.   You will just need to craft a regular-expression to pull the string apart, then you can just write the one statement to create the entire data structure, and it will “just work.™”

In reply to Re: hash magic by sundialsvc4
in thread hash magic by hrmnbth

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (5)
    As of 2018-03-21 07:51 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (264 votes). Check out past polls.