You could import them manually after the load:
#!/usr/bin/perl use 5.9.5; use strict; use warnings; use Module::Load::Conditional 'can_load'; BEGIN { my $modules = { map {$_ => undef} qw/ IPC::Cmd Time::HiRes /}; die "Please install required perl modules: \n". join ' ', 'cpan', keys(%$modules), "\n". join ' ', 'cpanm -v', keys(%$modules), "\n" unless can_load(modules=>$modules, autoload=>1); IPC::Cmd->import ('QUOTE'); Time::HiRes->import ('time'); } print join '', IPC::Cmd::QUOTE(), Time::HiRes::time(), IPC::Cmd::QUOTE(),"\n"; print join '', QUOTE(), time(), QUOTE(), "\n";
The BEGIN block is only really necessary because time() from Time::HiRes stomps on time so needs to be loaded at compile time. QUOTE works fine without.
In reply to Re: Imports with Module::Load::Conditional
by hippo
in thread Imports with Module::Load::Conditional
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |