in reply to Best way to copy an array?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Best way to copy an array?
by John M. Dlugosz (Monsignor) on Feb 23, 2004 at 04:37 UTC |