in reply to Undefining subroutines and inheritance

Maybe you have to delete the symbol-table hash key?

# UNTESTED! # Instead of undef &{B::A} delete $B::A::{CODE};

Update: Oh well. :-(

Update again! Ah-ha! This seems to work fine, even preserving $B::A (though I wouldn't think it would...):

# Instead of undef &{B::A} delete $B::{A};

Can anyone explain why that doesn't seem to destroy $B::A? It seems dangerous and prone to breakage, so you should probably use chromatic's suggestion below.

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.

Replies are listed 'Best First'.
Re: Re: Undefining subroutines and inheritance
by bikeNomad (Priest) on Jun 29, 2001 at 00:25 UTC
    Can anyone explain why that doesn't seem to destroy $B::A?

    Ah, but it seems to! Try replacing the bottom of the program with:

    A->A; # Why doesn't it just call A::A here because of inheritance? B->A; # Not a CODE reference at noinherit.pl line 27. eval "print \$B::A"; # Use of uninitialized value in print at (eval 2) + line 1.

      Hrm. I guess normal references to variables are bound at compile-time. Ah, well. Back to chromatic's method. *shrug*

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.

Re: Re: Undefining subroutines and inheritance
by dragonchild (Archbishop) on Jun 28, 2001 at 23:55 UTC
    Nope. I just tried it and it doesn't work. Nice thought, though...