我希望能够在列表中的每个模块上运行此测试。不确定如何使perl遍历每个项目。
use Module::Load;
eval {
load Image::Magick;
1;
} or die "you need Module to run this program";
Run Code Online (Sandbox Code Playgroud)
尝试一下:
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
my @modules = qw(
Bit::Vector
Carp::Clan
Check::ISA
DBD::Oracle
DBI
Tree::Simple
);
for(@modules) {
eval "use $_";
if ($@) {
warn "Not found : $_" if $@;
} else {
say "Found : $_";
}
}
Run Code Online (Sandbox Code Playgroud)