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
If you don't need to use Perl to do this, you could do this in a shell script:
#!/bin/sh
MODULES="Data::Dumper Foobar::Test"
for i in $MODULES ; do
if $(perl -M$i -e '1;' >/dev/null 2>&1 ); do
echo "Ok."
else
echo "No."
fi
done
You could do something else other than using echo
.
The code sequence:
perl -MData::Dumper '1;'
will exit with an error value of 0 (ok) and
perl -MFoobar::Test '1;'
will exit with an error value of 2 (error occurred).