Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Now you see it, now you don't

by crouchingpenguin (Priest)
on May 30, 2003 at 01:48 UTC ( [id://261736]=note: print w/replies, xml ) Need Help??


in reply to Now you see it, now you don't

Or you can use AUTOLOAD. I use it in my base classes, then setup the inherited object's attributes in the object initialization (which AUTOLOAD will check to see if they exist before granting access to them).

### our magic accessor generator sub AUTOLOAD { my $self = shift; my $auto = (split(/\:\:/,$AUTOLOAD))[-1]; $auto = $AUTOLOAD unless $auto; return if $auto eq 'DESTROY'; ### ignore die "No such method: $auto\n" unless (exists $self->{$auto}); if ( @_ ){ my @args = @_; if( scalar(@args) > 1){ $self->{$auto} = \@args; }else{ $self->{$auto} = $args[0]; } }else{ return $self->{$auto}; } }

cp
----
"Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found