On Wed, Apr 19, 2000 at 12:08:12PM -0400, [EMAIL PROTECTED] wrote:
> >>>>> "JNP" == Joshua N Pritikin <[EMAIL PROTECTED]> writes:
>
> >> sub privateData
> >> {
> >> my $obj = shift;
> >> my $key = shift || caller;
> >> $obj->{$key} ||= {};
> >> }
>
> i am not sure of why the need for private data per caller. i used the
> data attribute in a global way when i wrote event loops.
What if I inherit from your customized watcher and wish to store my own
private data? That was my hesitation all along, but now it looks
solved.
> JNP> sub data { # assumes $self is a HASH ref
> JNP> my $self = shift;
> JNP> my $pkg = caller;
> JNP> if (@_) {
> JNP> $self->{$pkg} = shift
> JNP> } else {
>
> drop the else. accessors should always return the value whether freshly
> set or not.
Yes, that how it works either way. Hash assignment returns the new
value; the else branch would be redundent.
--
"May the best description of competition prevail."
via, but not speaking for Deutsche Bank