On Nov 23, 2007, at 8:19 AM, brian d foy wrote:

If this were my problem, I think my first attempt would be writing my
own CPAN.pm script that set the environment and config just the way I
wanted it.

If you mean writing a script that uses CPAN.pm then that is what I have done. Something like this:

   use CPAN;
   my $settings = _get_settings();
   CPAN::HandleConfig->load();
   $CPAN::Config->{'makepl_arg'}   = $settings->{'makepl_arg'};
   $CPAN::Config->{'build_dir'}    = $settings->{'build_dir'};
   # Etc.
   # then later....
   foreach my $module_hash ( _get_modules_to_instal() ) {
       install_module($module_hash);
   }

   sub install_module {
       my $module_hash = shift;
       my $module_name = $module->{name};
       if ( $module->{diag} ) {
          diag( $module->{diag} );
       }

       my @args = ();
       if ( $module->{extra_args} ) {
          @args = @{ $module->{extra_args} };
       }
       push @args, $module_name;

       my $method = $module->{method};
       CPAN::Shell->$method(@args);

use_ok($module_name) || BAIL_OUT("failed to install $module_name");
      return TRUE;
   }

   sub _get_modules_to_install {
     my @modules = (
        { method => 'install', name => 'XML::Twig' },
        { method => 'install', name => 'DBI::DBD' },

        {   method     => 'notest',
            name       => 'DBD::mysql',
            extra_args => ['install'],
diag => 'notest install of DBD::mysql so we do not need a database.'
        },
     );
     return @modules;
   }

-------------------------------------------------------
Matisse Enzer <[EMAIL PROTECTED]>
http://www.matisse.net/  - http://www.eigenstate.net/



Reply via email to