in reply to Yet another does-function-exist question
Just call it and see what happens.
sub bar { print 'woot' } for my $thing (qw/ foo bar /){ print "$thing :$/"; eval{ no strict refs; &{$thing}(@_); # possibly a nasty symbolic reference }; warn "You can not call $thing: $@ " if $@; }
gives you something like:
foo : You can not call foo: Undefined subroutine &main::foo called at call l +ine 7. at call line 9. bar : woot
The main point being, that you can just catch the die from eval and move on.
Why ask if something looks like it will fail, when you can just suck it and see?
if you're involving objects, UNIVERSAL's can may also interest you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Yet another does-function-exist question
by xaprb (Scribe) on Apr 14, 2007 at 15:44 UTC | |
by f00li5h (Chaplain) on Apr 15, 2007 at 05:30 UTC | |
by Anonymous Monk on Mar 27, 2008 at 10:13 UTC | |
by f00li5h (Chaplain) on Apr 02, 2008 at 11:32 UTC |