in reply to Re: getting 2 things done at once with Class::Base
in thread getting 2 things done at once with Class::Base
Whatever he is doing, I completely do _not_ understand it:
He is returning a dereference of $errvar.
Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality
#--------------------------------------------------------------------- +--- # error() # error($msg, ...) # # May be called as a class or object method to set or retrieve the # package variable $ERROR (class method) or internal member # $self->{ _ERROR } (object method). The presence of parameters indic +ates # that the error value should be set. Undef is then returned. In the # abscence of parameters, the current error value is returned. #--------------------------------------------------------------------- +--- sub error { my $self = shift; my $errvar; { # get a reference to the object or package variable we're munging no strict qw( refs ); $errvar = ref $self ? \$self->{ _ERROR } : \${"$self\::ERROR"}; } if (@_) { # don't join if first arg is an object (may force stringification) $$errvar = ref($_[0]) ? shift : join('', @_); return undef; } else { return $$errvar; } }
Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: getting 2 things done at once with Class::Base (reading)
by tye (Sage) on Oct 31, 2007 at 15:43 UTC |
In Section
Meditations