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 ( #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


Comment on Re^2: getting 2 things done at once with Class::Base
Select or Download Code
Re^3: getting 2 things done at once with Class::Base (reading)
by tye (Cardinal) 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
Node Status?
node history
Node Type: note [id://648288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2015-07-07 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls