NOCpulse::Module.3pm

Langue: en

Autres versions - même langue

Version: 2010-05-04 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

NOCpulse::Module - safely loads a Perl module

SYNOPSIS

     use NOCpulse::Module;
     ...
     my $error = NOCpulse::Module::load($moduleName, $libDir);
     if ($error) {
         die "Cannot load $moduleName from $libDir: $error\n";
     }
 
     my @errors = NOCpulse::Module::load($moduleName, $libDir, 'NOCpulse::PlugFrame');
     if (@errors) {
         die "Cannot load $moduleName from $libDir: ".join(' ', @errors)."\n";
     }
 
 

DESCRIPTION

Provides methods to test if a Perl module is loaded, and to attempt to load one without blowing up if it cannot be found.

MODULE METHODS

load($moduleName [, $libDir [, $fallbackPackage])
First checks if the module has been loaded and returns true if so. Otherwise adds $libDir to the library path and tries to ``require'' the module ($libDir can be either a scalar or a ref to an array of scalars). If that fails, and $fallbackPackage is provided (which, again, can be either a scalar or an ref to an array of scalars), remembers the first error and tries to ``require'' the module in the fallback package. If that also fails, that error and the previous are returned. If there is no fallback package and there is an error, returns false and in array context returns (0 , @error_messages).
isLoaded($moduleName)
Returns defined if the module named $moduleName is known to Perl, undef otherwise.