in reply to Re: How to determine if a package method is defined
in thread How to determine if a package method is defined
defined &{$TEST->test_sub}
This would actually (try to) call the method...
#!/usr/bin/perl my $TEST = "foo"; if ( defined &{$TEST->test_sub} ) { } __END__ Can't locate object method "test_sub" via package "foo" (perhaps you f +orgot to load "foo"?) at ./798474.pl line 4. --- #!/usr/bin/perl my $TEST = "foo"; if ( defined &{$TEST->test_sub} ) { } package foo; sub test_sub { print "hi\n" } __END__ hi
|
|---|