diff options
| author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2014-01-16 20:06:49 +0000 |
|---|---|---|
| committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2014-01-16 20:06:49 +0000 |
| commit | 0ec58bfa3d152b9e214f52a7f2ca0aa9d7a09d6e (patch) | |
| tree | 46428bb9d42b0b78a66db5b0909f36fbbe4cb24b /cpan/Module-Load-Conditional/lib/Module | |
| parent | 73b1d836e48dd52697510e35fe72102cb3234946 (diff) | |
| download | perl-0ec58bfa3d152b9e214f52a7f2ca0aa9d7a09d6e.tar.gz | |
Update Module-Load-Conditional to CPAN version 0.60
[DELTA]
0.60 Thu Jan 16 12:28:24 GMT 2014
* Added autoload option to can_load()
Diffstat (limited to 'cpan/Module-Load-Conditional/lib/Module')
| -rw-r--r-- | cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm b/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm index c890df04cd..6e6099812f 100644 --- a/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm +++ b/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm @@ -2,7 +2,7 @@ package Module::Load::Conditional; use strict; -use Module::Load; +use Module::Load qw/load autoload_remote/; use Params::Check qw[check]; use Locale::Maketext::Simple Style => 'gettext'; @@ -22,7 +22,7 @@ BEGIN { $FIND_VERSION $ERROR $CHECK_INC_HASH]; use Exporter; @ISA = qw[Exporter]; - $VERSION = '0.58'; + $VERSION = '0.60'; $VERBOSE = 0; $DEPRECATED = 0; $FIND_VERSION = 1; @@ -319,7 +319,7 @@ sub check_install { return $href; } -=head2 $bool = can_load( modules => { NAME => VERSION [,NAME => VERSION] }, [verbose => BOOL, nocache => BOOL] ) +=head2 $bool = can_load( modules => { NAME => VERSION [,NAME => VERSION] }, [verbose => BOOL, nocache => BOOL, autoload => BOOL] ) C<can_load> will take a list of modules, optionally with version numbers and determine if it is able to load them. If it can load *ALL* @@ -329,8 +329,8 @@ This is particularly useful if you have More Than One Way (tm) to solve a problem in a program, and only wish to continue down a path if all modules could be loaded, and not load them if they couldn't. -This function uses the C<load> function from Module::Load under the -hood. +This function uses the C<load> function or the C<autoload_remote> function +from Module::Load under the hood. C<can_load> takes the following arguments: @@ -355,6 +355,12 @@ same module twice, nor will it attempt to load a module that has already failed to load before. By default, C<can_load> will check its cache, but you can override that by setting C<nocache> to true. +=item autoload + +This controls whether imports the functions of a loaded modules to the caller package. The default is no importing any functions. + +See the C<autoload> function and the C<autoload_remote> function from L<Module::Load> for details. + =cut sub can_load { @@ -364,6 +370,7 @@ sub can_load { modules => { default => {}, strict_type => 1 }, verbose => { default => $VERBOSE }, nocache => { default => 0 }, + autoload => { default => 0 }, }; my $args; @@ -436,7 +443,12 @@ sub can_load { if ( $CACHE->{$mod}->{uptodate} ) { - eval { load $mod }; + if ( $args->{autoload} ) { + my $who = (caller())[0]; + eval { autoload_remote $who, $mod }; + } else { + eval { load $mod }; + } ### in case anything goes wrong, log the error, the fact ### we tried to use this module and return 0; |
