*VAR
is the symbol table entry for the following:
(It also has a slot for a file handle, a directory handle, a format and more.)
Because they store a bunch of variables of different types, the symbol table entries are called "typeglobs", or "globs" for short.
Assigning a reference to a to a glob sets the slot of the appropriate type to the referenced variable. This means that assigning a reference to a scalar to *VAR
sets *VAR{SCALAR}
, the value returned by $VAR
. Since you are passing a reference to a constant, $VAR
returns that constant.
*VAR = *OTHER;
, on the other hand, makes the left-hand side name an alias for the right-hand side name.
- It makes
$VAR
equivalent to $OTHER
.
- It makes
@VAR
equivalent to @OTHER
.
- It makes
%VAR
equivalent to %OTHER
.
- It makes
&VAR
equivalent to &OTHER
.
- etc
*VAR = 0;
is treated as *VAR = *{"0"};
which means *VAR = *0;
. This means, among other things, that $VAR
will return the current script's name (as $0
would).
Reference: Typeglobs and Filehandles