in reply to When is my variable not really mine?
However, if you hand a reference to that variable to another area, or even a reference to a closure that has visibility of the lexical variable, the variable can be tweaked at will.
Note that a subroutine has limited "call-by-reference" semantics as well, if you directly alter @_ rather than copy the values, as is routinely suggested.
And even if you had a copy of a top-level value, if that copy contains references, then the references are pointers into your original data structure. To fully insulate yourself, you must perform a deep copy.
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: When is my variable not really mine?
by gaspodethewonderdog (Monk) on Sep 07, 2000 at 17:49 UTC | |
by Fastolfe (Vicar) on Sep 07, 2000 at 17:57 UTC | |
by gaspodethewonderdog (Monk) on Sep 07, 2000 at 19:03 UTC | |
by jcwren (Prior) on Sep 07, 2000 at 19:07 UTC |