in reply to Copying an array or hash

my @newArray = @$orig;
This, of course, has the caveat that it copies the contents, so if it's a huge array that might be bad memory-wise...

Other caveat is that is the elements themselves are hash/array/object references, this isn't what you what -- you'll need a deep copy. I haven't used one, but you should be able to find something in Super Search or possibly one of Clone, Clone::PP, or Clone::Any would fit your needs..

Replies are listed 'Best First'.
Re^2: Copying an array or hash
by tphyahoo (Vicar) on Dec 05, 2005 at 14:22 UTC
    I haven't done deep copying either, but I've read about it. Merlyn has a good column at Deep Copy and Recursion, which has a simple deep copy routine that should work for most situations, and suggests using Storable::dclone for particularly hairy deep copying.