Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: doubts about Data::Dumper output

by MidLifeXis (Monsignor)
on Oct 06, 2014 at 13:12 UTC ( [id://1102958]=note: print w/replies, xml ) Need Help??


in reply to doubts about Data::Dumper output

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

Replies are listed 'Best First'.
Re^2: doubts about Data::Dumper output
by Discipulus (Canon) on Oct 06, 2014 at 18:47 UTC
    Until the verbose answer of LanX and MidLifeXis i was not understanding the 'unordered keys' argument.

    Now it appears clear: the reference count! Two pointers share the same address: how can Data::Dumper or any other module tell who was set before?

    In such perspective the module behaviour had to expected in advance.

    Sometime trees conceal the wood.

    thanks
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1102958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-28 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found