in reply to Multiple Levels of Array Dereferencing Have me Stumped
It's a copy!# umm -- uh.... well, the @sign implies # we have an array, but how is it # different from the first array we # dereferenced?
it prints 'aa' and not 'a1' because @{[(list of refs)]} has built a copy of 'list of refs' protecting $ref1 from being altered by the assignment inside the funcionmy $ref1 = ['a','b','c']; my $ref2 = ['d','e','f']; my $refref = [$ref1, $ref2]; myfunc($refref); print $ref1->[0]; sub myfunc { my (@list) = @{[@{$_[0]}]}; print $list[0][0]; $list[0] = ['1','2','3']; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE (tilly) 2: Multiple Levels of Array Dereferencing Have me Stumped
by tilly (Archbishop) on Nov 05, 2000 at 23:11 UTC | |
by cianoz (Friar) on Nov 05, 2000 at 23:28 UTC | |
by tilly (Archbishop) on Nov 05, 2000 at 23:34 UTC | |
|
RE: Re: Multiple Levels of Array Dereferencing Have me Stumped
by Fastolfe (Vicar) on Nov 06, 2000 at 00:41 UTC | |
|
RE: Re: Multiple Levels of Array Dereferencing Have me Stumped
by mdillon (Priest) on Nov 05, 2000 at 22:29 UTC | |
|
(ar0n) RE (2): Multiple Levels of Array Dereferencing Have me Stumped
by ar0n (Priest) on Nov 05, 2000 at 22:49 UTC |