for my $meth (qw/ WriteLine Select Add /) { my $sub = sub { my $self = shift; my $it = $self->OStream->$meth($_[0]); $self->Trace(_CallerStr($it)); return $it; }; no strict 'refs'; *$meth = $sub; } #### package Wrapper; use Carp; sub new { my ($class,$wrapped) = @_; return bless \$wrapped, $class; } sub AUTOLOAD { my $wrapped = shift; (my $meth = our $AUTOLOAD) =~ s/.*:://; croak "Wrapped object $$wrapped doesn't have a method $meth" unless $$wrapped->can($meth); # do stuff here my $returnval = $$wrapped->$meth(@_); # call wrapped method # and more stuff here return $returnval; } sub DESTROY {} # don't autoload DESTROY