in reply to Re^3: Automating CPAN Configuration
in thread Automating CPAN Configuration
#!/usr/bin/perl -w use strict; # get the path to the library use Config; my $libpath = $Config{privlib}; # force CPAN::FirstTime to not default to manual # setup, since initial CPAN setup needs to be automated system("perl -pi -e\'\$. == 73 and s/yes/no/\' $libpath/CPAN/FirstTime +.pm"); # initialize the Config.pm file use Env; $ENV{PERL_MM_USE_DEFAULT} = 1; require CPAN; require CPAN::FirstTime; CPAN::FirstTime::init("$libpath/CPAN/Config.pm"); delete $ENV{PERL_MM_USE_DEFAULT}; # undo the change system("perl -pi -e\'\$. == 73 and s/no/yes/\' $libpath/CPAN/FirstTime +.pm"); # read in the Config.pm file open(CONFIGFILE,"<","$libpath/CPAN/Config.pm"); my @lines = <CONFIGFILE>; close CONFIGFILE; # ..delete it unlink "$libpath/CPAN/Config.pm"; # ..and then write it back out, replacing the line with the empty arra +y urllist with a filled in array open(NEWFILE,">","$libpath/CPAN/Config.pm"); foreach(@lines){ if($_ =~ m/urllist/){ print NEWFILE " \'urllist\' => [\'http://ppm.activestate.com/ +CPAN\', \'http://cpan.perl.org\'],\n";} else{ print NEWFILE $_;}} close NEWFILE; # install the packages CPAN::install('SOAP::Lite'); CPAN::install('XML::Simple'); 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Automating CPAN Configuration
by runrig (Abbot) on Jun 28, 2010 at 16:11 UTC |