I have made a script to intimate the admin the list of module need to be installed on machine .
I am trying to check wheather the module installed by underbelow code. The odd thing is that it is showing even installed module in the machine as not installed
#!/usr/bin/perl -w
my @module_list =('Smart::Comments','HTML::Parse');
foreach (@module_list) {
eval { require "$_" };
if (!($@)) {
print "Module Not installed : $_\n";
}
}
You need to use the string form of
evalbecauserequireneeds a bareword argument to match against the double-colon-separated form of the module name (e.g.Scalar::Util). (If it’s not a bareword, then it needs to be a relative path, e.g.'Scalar/Util.pm')