On Wed, Apr 19, 2000 at 08:36:21AM +0100, [EMAIL PROTECTED] wrote:
> Joshua N Pritikin <[EMAIL PROTECTED]> writes:
> >Granted. Perhaps the thing to do is to document that data() should
> >be reimplemented in every subclass to use a uniqueish key:
>
> Graham Barr came up with this for Tk:
>
> sub privateData
> {
> my $obj = shift;
> my $key = shift || caller;
> $obj->{$key} ||= {};
> }
Oh, that's clever. How about this?
=item data => $anything
Use the C<data()> method to associate arbitrary data with a watcher.
Each caller's package accesses its own private data attribute.
=cut
sub data { # assumes $self is a HASH ref
my $self = shift;
my $pkg = caller;
if (@_) {
$self->{$pkg} = shift
} else {
$self->{$pkg};
}
}
--
"May the best description of competition prevail."
via, but not speaking for Deutsche Bank