If you ask how to get a reference to the glob type, simply:
my $ref = \*symbol_name_here;
For the "literal name" of this character (that is, where you enter the exact name of the character), not a variable. But you can do it:
my $ref = Symbol::qualify_to_ref( $symbol_name );
for a variable symbol. However, the above works with strict , and the simpler one below:
my $ref = \*{$symbol_name};
One of the nice things about Symbol::qualify* is that it treats package names as a second variable. So that...
my $sref = Symbol::qualify_to_ref( $symbol_name, $some_other_package );
does the same as \*{$some_other_package.'::'.$symbol_name} , and works with strict .
Once you have the ref character in order to get this slot, you must respect the link, so perl doesn't think you're trying to use it as a hash, for example.
my $href = *{ $sref }{HASH}; my $code = *{ $sref }{CODE}; my $arref = *{ $sref }{ARRAY}; my $io = *{ $sref }{IO};
Another Take
I combined your two ideas in a different way. If you have a link to a symbol table, you can get a HASH slot, and this is a link, like any other hash link. Therefore, you can do the following.
Or
*hash{HASH}->{key}
or
${ *hash{HASH} }{key}
will work. It's safer though
( *hash{HASH} || {} )->{key}; ${ *hash{HASH} || {} }{key};
If you want to do this not with a direct record, but with a link to the table, you must do the following:
my $ref = \*hash; my $value = *{ $ref }{HASH} && *{ $ref }{HASH}->{key};
NOTE. %hash absolutely must be a package variable. Only package variables are in the symbol table (so only subs and @ISA and Exporter variables are usually found in modern symbol tables). Lexical variables (declared by my ) are in the "pad" .
UPDATE:
I have not used Symbol so much. Curiously, although this is the core, it seems unconventional in how Perler does - and sees - things. Instead, I use the direct path in what I call "no blocks" as localized as I can make them.
# All I want is one symbol.
OR
{ no strict 'refs'; *{$package_name.'::'.$symbol_name} = $sub_I_created; ...
I almost always use idiom *STDERR{IO} to reference the glob file descriptor. In modern Perl, these are usually objects.
my $fh = *STDERR{IO}; say blessed( $fh );