in reply to using arrays of arrays
There are numerous modules (such as the ones already described), or Storable’s dcopy function, which can help you here.
The essential problem here is that the easiest way to “copy a data structure” (or, that is to say, to think that you have done so...) involves the use of “references,” which are rather like “pointers” in other, more primitive languages. Doing a deep copy, using any of the tools described, guarantees that you are left with a new data structure.