This section describes symbol table and, typeglob and identifier aliases. The symbol table is a hash used by the compiler to store all identifiers used in the package.
Typeglob: A special data type used by Perl compiler for the symbol table.
Symbol Table: A hash used by Perl compiler for each name space (package).
The name of the symbol table hash is actually the package name followed with a double-colon, ::.
Keys in the symbol table are identifiers used in the name space.
Values associated with keys are typeglobs.
There are two ways to access typeglobs:
Using hash notation. For example, $main{identifier}.
Using * notation. For example, *main::identifier.
Since the same identifier can be used for different data types, there will be only
one entry in the symbol table for many variables of different data types, if they have
the sample identifier.
One common usage of typeglobs is to create identifier aliases. There are several ways
to create aliases:
1. Assigning one typeglob to another with "*" notations to create an alias for all data types.
For example, "*main::foo = *main::bar" - "foo" is an alias for "bar" for all data types.
2. Assigning one typeglob to another with hash notations to create an alias for all data types.
For example, "$main::{foo} = $main::{bar}" - "foo" is an alias for "bar" for all data types.
3. Assigning a hard reference to a typeglob to create an alias for one data type. For example
"*main::foo = \$main::bar" - "foo" is an alias for "bar" for scalar varialbe.
Aliases can be used in the same place as the original identifier.
Here is a program to show you how to create and use identifier aliases:
The first entry in the symbol table defines an empty string key. What's for?
Identifier alias assignment statements seem to be processes during
the compilation. This is why the symbolic table printed at the beginning
of the execution already contains "y" and "b".
$b[1] is undefined, because "b" is defined as an alias only for scalar variable.
I am using a symbolic reference to pass the hash variable name into
a subroutine.