Is there any way to tell whether a hash reference is referring to a symbol table?
That is, how could the function
sub foo {
my ($hashref) = @_;
...
}
know whether it had been invoked as
foo( \%main:: )
rather than
foo( \%main )
?
The application is a function that sometimes tie
's hash variables, but I'd want to avoid trying to tie a symbol table.
It looks like this can be done from the C API using HvNAME
. The following is from perlapi:
HvNAME
Returns the package name of a stash, or NULL if stash isn't a stash. See SvSTASH , CvSTASH .
- char* HvNAME(HV* stash)