All,
I've devised the following script to check if a CPAN module is installed on
a machine, and install it if it isn't.
The only problem is, the eval always fails and says it can't find the
module, and thus always installs it.
Also if I use "use" instead of "Require" it gives me compilation errors.

Having a brain dead day, anybody know where I'm going wrong?

regards

Marty




#!/usr/bin/perl

use CPAN;
use strict;

my @modules = (
             "MIME::Base64",
             "MD5",
             "URI",
             "LWP",
             "Data::Dumper",
             "IO::ScalarArray",
             "Time::HiRes",
             "Time::CTime",
             "Date::Format",
             "File::Spec",
             "Getopt::Long",
             "AppConfig",
             "Net::NNTP",
             "Net::FTP",
             "Net::SNMP",
             "NetServer::Generic",
             "Template",
             "DBI",
             "DBD::mysql",
             "Mail::Internet",
             "MIME::Parser",
             "XML::Parser",
             "XML::Simple",
               );

# Install modules
#
foreach my $mod ( @modules )
{
        eval {require $mod;};
        if ($@)
        {
                my $obj = CPAN::Shell->expand('Module',$mod);
                $obj->install
        }
}

print "\n\nDone.\n";

_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to