in reply to Re: Best way to copy an array?
in thread Best way to copy an array?

Am I missing something? What exactly is wrong with @newlist = @{$self->{oldlist}};?

I thought that doesn't copy anything, but aliases the array. You mean I'm copying a list every time I dereference it?!

No, 'cause push @{$self->{oldlist}}, $x does indeed modify the thing being remembered by self.

Ah, assigning to a @list naturally copies the elements and keeps the identity of the left-hand-side. That makes sence.

Thanks,
—John