in reply to Re^3: Detecting which class a method is defined in
in thread Detecting which class a method is defined in
I mean this behavior:
#!/usr/bin/perl -l $y='main';$A::y='A';$C::y='C'; package main; sub foo { $y } sub bar { $y } package A; *foo = \&main::foo; *bar = \&main::bar; package C; @C::ISA = 'A'; *bar = \&main::bar; package main; use B 'svref_2object'; my $x = bless {}, 'C'; for (qw(foo bar)) { print "$_ -> ", $x->$_, " from ", svref_2object(UNIVERSAL::can($x, + $_))->GV->STASH->NAME; }
If you know the name of the intended destination stash at the time of writing the code, your example works fine. It's not always possible to know that, unfortunately.
|
|---|