in reply to Undefining subroutines and inheritance

I did something similar in Devel::TraceMethods (hey, I invented a wheel!). The only approach that worked for me was to copy all the other typeglob slots to a temporary array, undefine the destination typeglob altogether, then assign a subroutine reference and the other references. In this case, $src is a reference to the symbol table containing the subroutine to wrap, and $symbol is the name of the subroutine in that table:
# save all other slots of the typeglob foreach my $slot (qw( SCALAR ARRAY HASH IO FORMAT )) { my $elem = *{ $src->{$symbol} }{$slot}; next unless defined $elem; push @slots, $elem; } # clear out the source glob # undef &{ *{$src->{$symbol}} } didn't work undef $src->{$symbol}; # replace the sub in the source $src->{$symbol} = sub { logCall->($symbol, @_); return $sub->(@_); }; # replace the other slot elements foreach my $elem (@slots) { $src->{$symbol} = $elem; } }