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')
use strict;
use warnings;
my @module_list = ('Scalar::Util', 'flibble');
foreach (@module_list) {
if (!eval "require $_") {
print "Module not installed: $_\n";
}
}
source
share