in reply to Checking if a subroutine has been defined in a package...
Easy! You can use typeglobs, like this:
Of course, if you want to check if an arbitary function exists, it's not quite as pretty:if (*package::foo{CODE}) { # Function package::foo exists. } else { # Function package::foo does not exist. }
Hope that you find the above useful.my $function = "package::foo"; { no strict qw/refs/; # We're going to use symbolic refs. if (*{$function}{CODE}) { # Function in $fuction exists. } else { # Function in $function does not exist. } }
Cheers,
Paul
|
|---|