In my code, I know I can write...
if ( defined &test_sub ) {
test_sub();
} else {
print "Subroutine doesn't exist";
}
This tests the existence of the test_sub subroutine without actually calling it.
If, though, I replace test_sub with a package method...
if ( defined &$TEST->test_sub ) {
TEST->test_sub;
} else {
print "Method doesn't exist";
}
I get
Not a CODE reference at (eval 22)[/opt/perl/5.8.0/lib/perl5db.pl:17] line 2, <STDIN> line 3.
Any suggestions what I'm doing wrong?