"Glob" is another name for "symbol table entry". Symbol table entries have multiple fields, one for each data type (scalar, hash, array, etc).
$abc = 'xyz'; print(${*{abc}{SCALAR}}, "\n"); # xyz
When you modify a package variable, you modify the data in the appropriate field of the appropriate symbol table entry.
$glob = *def = *abc; $abc = 'xyz'; print($abc , "\n"); # xyz print($def , "\n"); # xyz print(${$glob }, "\n"); # xyz print(${*{abc }{SCALAR}}, "\n"); # xyz print(${*{def }{SCALAR}}, "\n"); # xyz print(${*{$glob}{SCALAR}}, "\n"); # xyz
Same goes when you localize a package variable. You're localizing the SCALAR field of the symbol table entry. It doesn't matter how you get to the symbol table entry (be it $_ or $alias0, for example), because the value is not associated with the symbol ($_), but with the symbol table entry (${*_{SCALAR}}).
$glob = *def = *abc; $abc = 'xyz'; print($abc , "\n"); # xyz print($def , "\n"); # xyz print(${$glob }, "\n"); # xyz print(${*{abc }{SCALAR}}, "\n"); # xyz print(${*{def }{SCALAR}}, "\n"); # xyz print(${*{$glob}{SCALAR}}, "\n"); # xyz local $def = 'uvw'; print($abc , "\n"); # uvw print($def , "\n"); # uvw print(${$glob }, "\n"); # uvw print(${*{abc }{SCALAR}}, "\n"); # uvw print(${*{def }{SCALAR}}, "\n"); # uvw print(${*{$glob}{SCALAR}}, "\n"); # uvw
In short, *abc = *def; makes the symbols abc and def the same. Only changes to the globs can undo this. local $abc doesn't affect the glob *abc (or *def), only the scalar component of it.
In reply to Re^3: Understanding typeglobs and local()
by ikegami
in thread Understanding typeglobs and local()
by whio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |