R
Richard Trahan
Consider the following code:
package mypackage;
$x = 7;
otherpackage::mysub($x);
....
package otherpackage;
sub mysub
{
# retrieve variable name here
}
In mysub, I would like to retrieve the name mypackage::x, as well as
the variable type (SCALAR). How do I do that? I know how to use
caller() to retrieve the caller's package, and I know how to iterate
through the caller's symbol table to retrieve symbolic names
and existence of types, but I don't know how to associate one
of them with the alias to $x in mysub, i.e., $_[0].
Any help, please. Thanks.
package mypackage;
$x = 7;
otherpackage::mysub($x);
....
package otherpackage;
sub mysub
{
# retrieve variable name here
}
In mysub, I would like to retrieve the name mypackage::x, as well as
the variable type (SCALAR). How do I do that? I know how to use
caller() to retrieve the caller's package, and I know how to iterate
through the caller's symbol table to retrieve symbolic names
and existence of types, but I don't know how to associate one
of them with the alias to $x in mysub, i.e., $_[0].
Any help, please. Thanks.