The one-liner does not set Purity. Purity will cause a dummy placeholder to be generated in the second reference and a cleanup statement after. The do... stuff is just a placeholder until the cleanup happens.

In the one liner, the module does not care if the structure can be reconstituted properly -- it is just showing a person the logical structure of the data. Once Purity is set, then the data can actually be regenerated (other than the actual SUB contents). To facilitate this, a unique junk value needs to be generated, which is where the do{...} block comes in. Line 6 in your second snippet is where the cleanup happens, removing the junk value created by the do and replacing it with the same reference to the sub that is present when the reconstituted hash is created (lines 2-5, second code block).

(Update) Since, as has been previously mentioned, hashes are unordered, it really doesn't matter which is created first. It appears that the hash keys are sorted, but this may just be due to chance. The reconstituted data structure would be identical once the Purity-generated data has been executed.

--MidLifeXis


In reply to Re: doubts about Data::Dumper output by MidLifeXis
in thread doubts about Data::Dumper output by Discipulus

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.