Check the list of modules installed on the machine

I made a script for intimate administration the list of modules should be installed on the computer.

I am trying to verify the module installed under the below code. The strange thing is that it even shows the installed module in the machine asnot installed

    #!/usr/bin/perl -w
    my @module_list =('Smart::Comments','HTML::Parse');
    foreach (@module_list) {
      eval { require "$_" };
      if (!($@)) {
        print "Module Not installed : $_\n";
      }
    }
+5
source share
2 answers

You need to use a string form evalbecause requirean open-word argument is required to match the form of the module name (e.g. Scalar::Util) with a double column. (If this is not a goblin, then this should be a relative path, for example 'Scalar/Util.pm')

#!/usr/bin/perl

use strict;
use warnings;

my @module_list = ('Scalar::Util', 'flibble');

foreach (@module_list) {
    if (!eval "require $_") {
        print "Module not installed: $_\n";
    }
}
+5
source

App:: Module:: Lister, , , , CGI script. , , FTP-.

Perl, , . , .

, , , , , . .

+1

All Articles