we mentioned earlier, can be localized (with
only) and assigned to one another. Assigning a typeglob has the
effect of aliasing one identifier name to another. Consider
$spud = "Wow!"; @spud = ("idaho", "russet"); *potato= *spud; # Alias potato to spud using typeglob assignment print "$potato\n"; # prints "Wow!" print @potato, "\n"; # prints "idaho russet"
Once the typeglob assignment is made, all entities that were called
“spud” can now also be referred to as
“potato”—the names are freely interchangeable. That
$potato are the
same thing, and so are the subroutines
&potato. Figure 3.2
shows the picture after a typeglob assignment; both entries in the
symbol table end up pointing to the same typeglob value.
Figure 3-2. Assigning *spud to *potato: both symbol table entries point to the same typeglob
The alias holds true until the typeglob is reassigned or removed. (We
will shortly see how to remove a typeglob.) In the example, there is
no subroutine called
spud, but if we define it
after the typeglobs have been assigned, that
subroutine can also be invoked as
potato. It turns
out that the alias works the other way too. If you assign a new list
@potato, it will also be automatically
For now, there is no easy, intuitive way to get rid of an alias created by a typeglob assignment (you may reassign ...