sub check_modules { my @mod_list = @_; print "\nI will check to see that you have all the required Perl modules...\n\n"; my @not_installed; for my $module ( @mod_list ) { eval "require $module"; printf "%-20s", $module; if ( $@ ) { print "Not Installed\n"; push @not_installed, $module; } else { print "OK\n"; } } if ( @not_installed ) { print " The following module(s) are not installed: @not_installed\n Would you like me to try to install them (y/n)? "; if ( <> =~ m/y/i ) { install_modules( @not_installed ); print " If everything seemed to go OK we can now continue. If the automatic install failed you will need to exit now and install the module(s) by hand. Note the names of the missing modules and see the file INSTALLING_MODULES for detailed instructions. Continue (y/n)? "; exit if <> =~ /n/i; } } } sub install_modules { my @modules = @_; print "\nI will now try to install module(s) @modules\n\n"; if ( $OS =~m/MSWin32/ ) { print " You are using $OS so I can try to do the install with ppm (ActiveState's Perl Package Manager) or CPAN. What shall we try? Hint: Try ppm first p = ppm, c = CPAN (p/c)? "; <> =~ m/p/i ? ppm_install( @modules ) : cpan_install ( 'win32', @modules ); } else { print " If you are using Debian I can use either apt-get or CPAN. What shall we try? c = CPAN, a = apt-get (c/a)? "; <> =~ m/a/i ? apt_get_install( @modules ) : cpan_install ( '', @modules ); } } sub cpan_install { my ($win32, @modules) = @_; my $quote = $win32 ? '"' : "'"; print " I will now try to install the missing modules using the CPAN shell. If you have not used this before you will need to answer a number of initialization questions. You can generally just accept the defaults and it will work. Unfortunately if you have not used it before and try to use it here it will hang invisibly waiting for your input, so you will need to run it from the command line using the command below....\n\n"; for my $module ( @modules ) { my $cmd = 'perl -MCPAN -e ' . $quote . 'install '. $module . $quote; print "Trying to install $module command line $cmd\nPlease be patient.....\n"; print `$cmd`; } } sub ppm_install { my @modules = @_; print " I will now try to install the missing modules using the ppm shell.....\n\n"; for my $module ( @modules ) { my $cmd = qq!ppm install "$module"!; print "Trying to install $module, command line $cmd\nPlease be patient.....\n"; print `$cmd`; } } sub apt_get_install { my @modules = @_; print " I will now try to install the missing module with apt-get.....\n\n"; for my $module ( @modules ) { my $cmd; $cmd = 'apt-get install libcgi-perl' if $module eq 'CGI'; $cmd = 'apt-get install libdbi-perl' if $module eq 'DBI'; $cmd = 'apt-get install libmail-pop3client-perl' if $module eq 'Mail::POP3Client'; $cmd = 'apt-get install libmime-perl' if $module eq 'MIME::Base64'; $cmd = 'apt-get install libmime-lite-perl' if $module eq 'MIME::Lite'; $cmd = 'apt-get install libcrypt-blowfish-perl' if $module eq 'Crypt::Blowfish'; $cmd = 'apt-get install libcrypt-cbc-perl' if $module eq 'Crypt::CBC'; $cmd = 'apt-get install libnet-perl' if $module eq 'Net::SMTP'; $cmd = 'apt-get install libtext-perl' if $module eq 'Text::Wrap'; print "Trying to install $module, command line $cmd\nPlease be patient.....\n"; print `$cmd`; } }