in reply to inheritance and can
In general, it's tough, partly because Perl's such a dynamic language and partly because it's a question of design. If I were in your shoes, I'd likely save the class name as it came into the constructor.
If you really need to compare references, one approach is take a reference to the method within the class. It's easiest to do that with symbolic references. That should be one warning against the idea...
package Foo; sub foo {} package Bar; @Bar::ISA = 'Foo'; sub bar {} package main; my $bar = bless {}, 'Bar'; my $foo = $bar->can( 'foo' ); my $fooinbar = do { no strict 'refs'; my $subname = ref $foo . '::foo'; \&{ ref $foo . '::foo' } if defined *{ $subname }{CODE}; }; print "$foo -> $fooinbar\n";
|
|---|