Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: getting 2 things done at once with Class::Base

by princepawn (Parson)
on Oct 31, 2007 at 15:39 UTC ( [id://648288]=note: print w/replies, xml ) Need Help??


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.
#--------------------------------------------------------------------- +--- # 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

    He returns undef unless no arguments were given. Not particularly complex code. Even documented:

    The presence of parameters indicates [...]. Undef is then returned. In the abscence of parameters­, the current error value is returned.

    His comments would be clearer if he changed one period into a semicolon, however.

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://648288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found