In a program I am writing, I have a 3D array of hashes implemented through extensive use of references. One of my procedures makes changes to the underlying data in that structure. However, I would like to keep a second copy of the original structure in memory in order to restore it if needed. I could do this with loops by dereferencing every element of the structure but I figure this is expensive in terms of processing time.
Is there a way to simply take a reference to a structure and generate a second reference to a completely separate but identical structure? I suspect there is not, but if there is, it would be worth 100 points.