Thank you one and all for your concise responses. I am sorry if I was a bit unclear and less than speedy in responding to the posts. I should have made my intentions clear; I don't have much experience with asking questions in a public forum like this one.
Essentially, I am creating a simple class, consisting of a constructor and an a method. The argument to the constructors sets the value of the datum, while the sub grants access to the datum.
I wanted to get around using explicit accessor and mutator methods and simply have a subroutine which, with a little syntactic sugar, could be used as a variable. I know, it sounds insane. Ne'ertheless, I shan't delve into my madness here.
My thinking, as unclear as it may seem, led me to believe a glob value could serve this dual purpose if one derefernced it properly:
package datum; our $value = undef; sub new { my $class = shift; local $value = shift; return bless { datum => $value, glob => *value }, $class } sub value { my $self = shift; return $self{glob} } 1
This "wants" to have the effect of returning an alias for the datum when used in a manner similar to the following:
use datum; my $d = datum->new(42); *d = $d->value(); # What I want to be able to here is something like: # $d = ...; $d->{foo} = ...; push @d, ...
Perhaps, this makes things a little more clear. Thank you in advance.
In reply to Re: Returning and using a glob from a sub.
by mephtu
in thread Returning and using a glob from a sub.
by mephtu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |