in reply to (Ovid - Dang, I love this place -- and one more question :)
in thread Typeglobs and Symbol tables

Ovid asks: Wondering one thing, though: if a object is a subclass of CGI.pm. is it possible for it to not have the param() method? If so, I'll need to test for $cgi->can('param'). If it is possible to inherit from a module but not inherit all methods, how would that be done?

First I figured you could undef a subroutine:

package MyCGI; use base CGI; undef(*MyCGI::param);
But then I realized that the subroutine wasn't defined in MyCGI, it was defined in CGI. So I don't think you can undef an inherited routine. But I'm not sure...

Update: would it be possible to (instead of using @ISA for inheritance) copy all of the subroutine refs from the parent class symbol table into your own and then delete one of them? I'll look into it...

Later: yes, you can copy from a superclass instead of using @ISA:

package A; sub abc { "abc\n" }; sub def { "def\n" }; package B; # inherit from A all but A::def foreach my $symname (keys %A::) { next if $symname eq 'def'; $B::{$symname} = $A::{$symname}; } my $b = bless({}, 'B'); print $b->abc; # prints "abc\n" print $b->def; # no such method