What your code is doing is calling the subroutine "$package::$funcName", and checking if it returns a defined value. This is certainly not what you want to be doing, because if the subroutine does not exist, you end up with a fatal errror.
If your subroutine does exist, you've just invoked it with no arguments, and it could return undef just to spite you anyway.
Rather than calling the subroutine, you instead want to use globs to access perl's symbol table. This is described in my reply above. It also happens to be a bit faster than methods using can(), since inheritance is not checked.
Cheers,
Paul
In reply to Re: Re: Checking if a subroutine has been defined in a package...
by pjf
in thread Checking if a subroutine has been defined in a package...
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |