I'm wondering how I would go about doing this:
package Something;
our $secret = "blah";
sub get_secret {
my ($class) = @_;
return; # I want to return the secret variable here
}
Now when I go
print Something->get_secret();
I want it to print blah
. Now before you tell me to just use $secret
, I want to make sure that if a derived class uses Something
as base, and I call get_secret
I should get that class' secret.
How do you reference the package variable using $class
? I know I can use eval
but is there more elegant solution?