1: ####################################################################
2: # sub
3: # testFunction
4: #
5: # purpose
6: # takes a module name and function name, returns true if the
7: # function exists in the module
8: #
9: # syntax: testFunction("Mine::Module", "myFunction");
10: #
11: sub testFunction {
12: my ($modname, $funcname) = @_;
13:
14: my $pkgname = $modname.".pm";
15: $pkgname =~ s/\:\:/\//g; #this is UNIX Specific
16:
17: #we use eval to avoid requiring a pkg which doesn't exist
18: eval '
19: no strict;
20: require($pkgname);
21: local *stash = *{ "${modname}::" };
22:
23: return unless defined &{ $stash{$funcname} };
24: 1;
25: ';
26: }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: testFunction
by johannz (Hermit) on Mar 23, 2000 at 23:05 UTC | |
|
RE: testFunction
by Anonymous Monk on Mar 24, 2000 at 08:57 UTC |