in reply to Imports with Module::Load::Conditional
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Imports with Module::Load::Conditional
by Eily (Monsignor) on Sep 20, 2019 at 14:15 UTC | |
|
Re^2: Imports with Module::Load::Conditional
by Anonymous Monk on Sep 20, 2019 at 15:19 UTC |