in reply to (MeowChow - tied local wierdness) Re3: Aliasing Variables
in thread Aliasing Variables
However, using Alias, e.g. from the module:
The Alias re-binds the symbol @DYNAMIC, essentially the same as *DYNAMIC=$tmp;. @DYNAMIC now aliases @$tmp.@DYNAMIC = qw(m n o); { local @DYNAMIC; alias DYNAMIC => $tmp, PERM => $tmp; $DYNAMIC[2] = 'zzz'; # prints "abzzzd|abzzzd|abzzzd" print @$tmp, "|", @DYNAMIC, "|", @PERM, "\n"; } # prints "mno|pqr" print @DYNAMIC, "|", @PERM, "\n";
But look at the local. It will restore the list @DYNAMIC, which means it will un-do this binding operation. If going out of scope does a STORE as you show, essentially @DYNAMIC=@saved;, it will overwrite the contents of @$tmp, as opposed to restoring the action of the *DYNAMIC=$tmp;. Follow me? He did not say local *DYNAMIC.
If local worked by pointing the symbol to a new SV, then there would be no need to FETCH/STORE, and the tie would not be preserved.
So there is still more to it than meets the eye.
—John
|
|---|