>>>>> "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.


  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.

        $self->{$pkg} = shift if @_ ;
        $self->{$pkg};

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

Reply via email to