in reply to Re: How to change the symbol table to wrap a sub in another sub ?
in thread How to change the symbol table to wrap a sub in another sub ?
I always thought that if you take a reference, and then change the underlying typeglob, then the referent must now refer to the new typeglob.
Why would it do that? If Perl worked that way, it would need two types of references. One would work for items not in a symbol table (anonymous data structures and subroutines, for example, or references to lexicals) and the other would always look up the referent through the symbol table for each access.
... why does $real_new still refer to the contents of the old CODE slot?
Because perl does the lookup once, finds the contents, and makes a reference to it. Changing what's in the slot after you've already fetched something from the slot only changes what's currently in the slot. It doesn't change what was in the slot previously.
|
|---|