If you're going to call the sub anyway, call it in an eval and see what happens. If some other error comes up, you can rethrow it with die.
eval { &$sub }; if ( $@ =~ /^Undefined subroutine/ ) { # This is what happens when you call a bogus sub ref. } elsif ( $@ ) { die $@; }
In reply to Re: How do I test the validity of a CODE reference?
by kyle
in thread How do I test the validity of a CODE reference?
by pilap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |