assignments made to the copy don't affect the original, but the elements reference the same things initially.Am I missing something? What exactly is wrong with @newlist = @{$self->{oldlist}};? What do you mean by "reference the same things initially?" Is this an array of references? Maybe you mean something like
but it's hard to tell..@newlist = map { [ @$_ ] } @{ $self->{oldlist} }; @newlist = map { { %$_ } } @{ $self->{oldlist} };
blokhead
In reply to Re: Best way to copy an array?
by blokhead
in thread Best way to copy an array?
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |