Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: avoiding overwriting variables in an inherited class

by choroba (Cardinal)
on Apr 21, 2012 at 14:55 UTC ( [id://966371]=note: print w/replies, xml ) Need Help??


in reply to avoiding overwriting variables in an inherited class

Another approach is to add another level into the hash:
package FunnyEmail; use strict; use warnings; use Email::Simple; sub new { my $class = shift; my $simple = Email::Simple->new(...); my $self = {simple => $simple}; bless $self, $class; }
Now, you have to redirect all the methods of Email::Simple into the subhash:
our $AUTOLOAD; sub AUTOLOAD { my $self = shift; my $simple = $self->{simple}; my $method = (split /::/, $AUTOLOAD)[-1]; if ($simple->can($method)) { $simple->$method(@_); } else { die "Cannot run $method\n"; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-29 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found