One solution would be to use Class::Delegation. For example:
package My::LibXML::Document; # all method calls in this class should be # delegated to the object in 'base' use Class::Delegation send => -ALL, to => 'base'; sub new { my $class = shift; my $self = bless { base => XML::LibXML::Document->new('1.0','UTF8'), listeners => [1,2,3], # or whatever }, $class; return($self); }; sub listeners { my $listeners = shift->{listeners}; return(@$listeners); }; package main; my $o = My::LibXML::Document->new; print $o->encoding, "\n"; # same as doing $o->{base}->encoding; print join(", ", $o->listeners), "\n";
Unless your code explicitly checks that My::LibXML::Document isa XML::LibXML::Document you should bee fine.
In reply to Re: Anonymous Scalar Ref to Hash?
by adrianh
in thread Anonymous Scalar Ref to Hash?
by acalbazana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |