in reply to Strange array reference behaviour (bug?)
That is the intended behavior. It allows a reference to be passed to a sub which may alter the content, just as may be done with pointers in C.
Your loop alters @$ref because you tell it to. $test is an alias to each element in turn.
You can force copying of the array with,
or,for (my @foo = @$aref) { #... }
for (@{[@$aref]}) { #... }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: Strange array reference behaviour (bug?)
by dragonchild (Archbishop) on Aug 12, 2003 at 16:39 UTC | |
|
Re: Strange array reference behaviour (bug?)
by agrundma (Novice) on Aug 12, 2003 at 17:15 UTC |