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.