perl script to check if perl modules are installed

前端 未结 4 1405
无人共我
无人共我 2021-01-20 19:27

I\'d like to be able to run this test on each module in the list. Not sure how to ger perl looping over each item.

use Module::Load;
eval {
  load Image::Mag         


        
4条回答
  •  不要未来只要你来
    2021-01-20 20:28

    Have a try with:

    #!/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 : $_";
        }
    }
    

提交回复
热议问题