What about using can...
eval do { local $/; <DATA> }; # psuedo require! die $@ if $@; for my $sub ( 'foo', 'undefined' ) { if ( main->can($sub) ) { main->$sub; } else { print "$sub() not defined\n"; } } __DATA__ sub foo { print "foo() worked\n"; }
In reply to Re: How do I test the validity of a CODE reference?
by FunkyMonk
in thread How do I test the validity of a CODE reference?
by pilap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |