in reply to How do I test the validity of a CODE reference?
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 $@; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I test the validity of a CODE reference?
by Your Mother (Archbishop) on Aug 08, 2008 at 01:07 UTC |