Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello

On macOS I use clone-modules command for perlbrew in order to reinstall a set of CPAN installed module in a new version of Perl. Now I need to work on Windows (Strawberry Perl, Portable, Berrybrew): is there any easy way to automate the installation of my set of CPAN module in the new Perl version? For now I am doing it manually... but as they are around 30 I guess a better method should be used...

Replies are listed 'Best First'.
Re: Install set of modules in new Perl
by stevieb (Canon) on Mar 15, 2019 at 23:23 UTC

    Taken from my post here, you can use bundles to gather all CPAN distributions installed, and then re-install them into your new perl installation:

    cpan -a ... Wrote bundle file /home/steve/.cpan/Bundle/Snapshot_2018_01_12_00.pm # move the Snapshot pm file to your ".cpan/Bundle" dir # switch to the new perl you want to install the distributions into cpan Bundle::Snapshot_2018_01_12_00.pm

    That example is on Linux, but it should be easy enough to follow.

    Note that I'm the author of berrybrew, and having the ability to 'clone' installed distributions from one perl instance into another is on my roadmap for this spring.

Re: Install set of modules in new Perl
by pryrt (Abbot) on Mar 15, 2019 at 23:24 UTC

    Hello. stevieb has "clone modules" in his TODO list, but I haven't seen any commits yet that indicate he's working on it. He's had a rather eventful life recently, and berrybrew isn't his primary focus: I don't blame him. In the past, I've added some small stuff to berrybrew, but I'm not even sure what all would be required to implement "clone modules", let alone how I'd go about it, so I unfortunately won't be able to help move this one forward.

    As a suggestion for how to improve upon "doing it manually", making a Bundle:: "module" helps. Hmm, mine's in a private svn repo, not in my github. Basically, all you need is a Makefile.PL that lists the prerequisites, and a dummy .pm, and you can then run cpanm --installdeps . (assuming you're in the right directory, and use cpanm; you can use the traditional perl Makefile.PL; make; make install sequence as an alternative). A simplified version of my Makefile.PL is below:

    use ExtUtils::MakeMaker; use strict; use warnings; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. my %mm_args = ( 'NAME' => 'Bundle::Pryrt', 'AUTHOR' => 'Peter C. jones <petercj AT cpan.org>', 'VERSION_FROM' => 'dummy.pm', 'ABSTRACT_FROM' => 'dummy.pm', 'PREREQ_PM' => { 'Pod::Markdown' => 0, 'Test::More' => 0, 'Devel::Cover' => 0, 'Module::Signature' => 0, }, ); { no warnings; if( $ExtUtils::MakeMaker::VERSION >= '6.31' ) { $mm_args{LICENSE} = 'perl_5'; } if( $ExtUtils::MakeMaker::VERSION >= '6.48' ) { $mm_args{MIN_PERL_VERSION} = '5.10.0'; } if( $ExtUtils::MakeMaker::VERSION >= '6.52' ) { $mm_args{CONFIGURE_REQUIRES} = { 'ExtUtils::MakeMaker' => 0, }, } } WriteMakefile( %mm_args )

    edit: as a publically-available example, some users keep their bundle's on CPAN, such as Bundle::BDFOY, so you can see how someone much more experienced than I does it. (but I wouldn't recommend putting yours in CPAN, unless you've got a following, or think other people would actually be interested in your bundle.)

      "In the past, I've added some small stuff to berrybrew..."

      Your efforts go well above and beyond "some small stuff". You single-handedly put in the entire berrybrew use ... functionality (which I use very often), as well as revamped the entire test infrastructure to make it far more dynamic (and usable).

      My development of berrybrew became a lot more efficient after these significant pieces were added.

      Thanks again :)