If you have a stock load of modules I would be inclined to tar the whole lot up. Then just untar them. Iterate through the dirs and shell out to install them. The advantage of this approach is that you will get all the versions that you have presumably been using in development.

use Cwd; my $cwd = cwd(); # untargz everything in current dir for my $tgz( glob("$cwd/*.tar.gz") ) { print `tar -xzf $tgz`; } opendir DIR, $cwd or die $!; my @dirs = grep{ -d $_ and ! m/^./ } readdir DIR; closedir DIR; for my $dir ( @dirs ) { chdir "$cwd/$dir"; print `perl Makefile.PL && make && make test && make install`; }

If you are on *nix you could open a pipe to the shell so you can see what is happening during the install....

Here is some code I wrote a while back the from memory works OK. It does not check for versions which may be important. For example only the latest CGI.pm and CGI::Simple support P3P, the latest DBI has some useful feature, etc, etc:

sub check_modules { my @mod_list = @_; print "\nI will check to see that you have all the required Perl m +odules...\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 w +e 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 w +ill 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`; } }

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Install modules thru a script by tachyon
in thread Install modules thru a script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.