I'm trying to install modules from CPAN in an automated fashion.  That is 
to say, I'm tyring to download stuff and have it install from a script.

I'm wondering if anyone has any general advice.  Currently I'm having 
problems with perl core dumping, and I wondered if it's caused by me doing 
anything stupid.

My install routines look something like

sub cpan_install
{
  my $module = shift;
  my %args = shift;

  # check if it's installed already
  if (not_installed($module, $args{version}))
  {
     # copy the varibles in the config
     local $CPAN::Config->{makepl_args} =
       (exists $args{makepl_args}) ? $args{makepl_args} : 
                          $CPAN::Config->{makepl_args};
     local $CPAN::Config->{make_args} =
       (exists $args{makepl_args}) ? $args{makepl_args} : 
                          $CPAN::Config->{makepl_args};
     local $CPAN::Config->{make_install_args} =
       (exists $args{makepl_args}) ? $args{makepl_args} : 
                          $CPAN::Config->{makepl_args};
 
     # work out what the module is we're talking about
     my $obj = CPAN::Shell->expand("Module", $module);

     # install in the correct manner for the args passed
     if ($args{force})
     {
        $obj->force
     }
     else
     {
        $obj->install
     }
  }
}

and it uses the support function

sub not_installed
{
    my $module = shift;
    my $version = shift;
    
    # eval it in a made up package name in order to see if
    # it's installed (without importing symbols)
    
    eval "package Fake::$module; use $module $version ()";
    if ($@)
    {
        print "$module not installed\n";
        return 1;
    }
    {
        print "$module already installed\n";
        return 0;
    }
}

And it's called by doing something like:

cpan_install("Template",
             version     => 2.06,
             make_plargs => "TT_QUIET=y TT_ACCEPT=y");

Now it's working okay some of the time, other times it core dumps.  
Whenever I get a situation when I core dump, it works fine from the 
interactive shell.  Am I forgetting to do something completely obvious?

Should I be using a completely different approach?

I'm having problems with XML::Parser[1] and XML::Handler::YAWriter mainly, 
but I see no reason why these should be special.

Later.

Mark.

[1] Yes, I have installed the latest expat from sourceforge.


-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}


Reply via email to