After several Days of working this out, I finally got it to work. The finished result is below. Thanks for Perl Monks for the ideas from this thread. Wouldn't have been able to do it without you!
#!/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;
|