0: ####################################################################
1: # sub
2: # testFunction
3: #
4: # purpose
5: # takes a module name and function name, returns true if the
6: # function exists in the module
7: #
8: # syntax: testFunction("Mine::Module", "myFunction");
9: #
10: sub testFunction {
11: my ($modname, $funcname) = @_;
12:
13: my $pkgname = $modname.".pm";
14: $pkgname =~ s/\:\:/\//g; #this is UNIX Specific
15:
16: #we use eval to avoid requiring a pkg which doesn't exist
17: eval '
18: no strict;
19: require($pkgname);
20: local *stash = *{ "${modname}::" };
21:
22: return unless defined &{ $stash{$funcname} };
23: 1;
24: ';
25: }
In reply to testFunction by nate
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |