#!/usr/bin/perl use strict; my $ok = "OK"; my $err = "Fail"; my @modules = ( {module=>'CGI', file=>'CGI.pm', redhat=>'perl-CGI', debian=>'libcgi-pm-perl'}, {module=>'DBI', file=>'DBI.pm', redhat=>'perl-DBI', debian=>'libdbi-perl'}, {module=>'DBD::mysql', file=>'DBD/mysql.pm', redhat=>'perl-DBD-MySQL', debian=>'libdbd-mysql-perl'}, {module=>'Digest::SHA', file=>'Digest/SHA.pm', redhat=>'perl-Digest-SHA', debian=>'libdigest-sha-perl'}, {module=>'LWP', file=>'LWP/UserAgent.pm', redhat=>'perl-libwww-perl', debian=>'libwww-perl'}, {module=>'Crypt::SSLeay', file=>'Crypt/SSLeay.pm', redhat=>'perl-Crypt-SSLeay', debian=>'libcrypt-ssleay-perl'}, {module=>'Time::HiRes', file=>'Time/HiRes.pm', redhat=>'perl-Time-HiRes', debian=>''}, ); my @failed_modules = grep { ! eval { require $_->{file} } && $@ } @modules; my %is_failed = map { $_->{module} => 1 } @failed_modules; my @redhat_pkgs = map { $_->{redhat} } @failed_modules if -e '/usr/bin/yum'; my @debian_pkgs = map { $_->{debian} } @failed_modules if -e '/usr/bin/apt-get'; print "Content-type: text/html\n\n"; print "Testing modules...

\n"; print "\n"; for(@modules) { my $status = $is_failed{ $_->{module} } ? $err : $ok; print "\n"; } print "
$_->{module}...$status

\n"; if(@failed_modules) { print "It looks like there are some Perl modules are missing.
\n"; print "You can install all of them at once by issuing the following command from root SSH console:

\n" if @redhat_pkgs || @debian_pkgs; printf ("yum install %s", join(' ', @redhat_pkgs)) if @redhat_pkgs; printf ("apt-get install %s", join(' ', @debian_pkgs)) if @debian_pkgs; } else { print "Everything is ready.\n"; }