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

I prostrate myself before the wisdom of the PerlMonks and beg they satisfy my inquiry. I have an old XP box that has about 3 years of modules grabbed with CPAN and PPM. I just set up a new box using primarily XP. How can I get all of those old modules onto the new box? I've searched the usual sources but I get a lot of chaotic kickback on my searches owing to the use of the terms backup or export. I am not sure how to go about seeking the answer. I thank you for your help.
  • Comment on How to move 3 years of modules to my new XP box?

Replies are listed 'Best First'.
Re: How to move 3 years of modules to my new XP box?
by Corion (Patriarch) on Nov 26, 2008 at 17:57 UTC

    See the autobundle command of CPAN. This will give you a (long) list of all modules installed into your Perl. Unfortunately, that list will also contain modules in the Perl core and modules installed because they are prerequisites to other modules you actually wanted to use directly. To weed out modules that are in the Perl core, see Module::CoreList. I don't know of any way to conveniently find out the modules that are just prerequisites for other modules.

      Corion,
      I am curious as to how autobundle will help. The question being asked isn't "how do I get a list of modules installed so that I can install them fresh" (though that's certainly 1 option), it is "how can I copy the directories and files from one machine to the other". I think that's mostly just copying the perl directory but given that some XS modules installed with PPM may also install 3rd party libraries in non-perl directories, I don't think this will work for every module.

      Of course, I could have completely misread the question too.

      Cheers - L~R

        Corion is being a little too terse.

        Once you've used the CPAN.pm or CPANPLUS.pm system to create an autobundle file on one machine, you can copy it to another machine and use the CPAN or CPANPLUS "install" command on the bundle file and it will automatically install the modules from cpan. This takes awhile, and it's far from painless, but I think it's more likely to work that just trying to copy perl installations from one box to another (remember: some "perl" modules contain C code that needs to be compiled and any architectural changes will screw these up. And aren't you upgrading your perl version? The perl version is in the path to your modules, and I suggest that it's there for a reason).

        So what you do is something like this:

        perl -MCPANPLUS -e'shell' b
        Or alternately:
        perl -MCPAN -e'shell' autobundle

        Note that when it finishes it will tell you where it wrote the bundle file.

        Bundle files are modules that contain only POD, with a CONTENTS section that contains the actual listing of module names, associating module name with version number.

        Chromatic's "Perl Hacks", provides a script (Hack #32) to trim modules from a bundle if they are listed in Module::Corelist.

        An even worse problem in my opinion is that this system tries to preserve version numbers. You're far more likely (for a development machine, at least) to want the latest version of everything than a precise clone of the original.

        You can do that by hacking the bundle file first, and by replacing all the version numbers (the second column) with the string 'undef'.

        Then, after copying your hacked bundle file to the target machine, you once again run either the CPAN.pm or CPANPLUS.pm shell and use the "install" command on the bundle.

        You must have CPAN/CPANPLUS set up to deal with dependencies automatically, otherwise this is useless.

        Even so, it's likely you'll run into snags along the way. You'll have to get very lucky to just let the install chug over night. More likely, you'll find it got stuck on some problem you'll need to solve manually and then re-start.

        I suggest that before restarting you make note of the last successfully installed module, and delete the ones that you don't need to look at again from the bundle file.

        If any of this sounds fugly, it's because it is. This is a problem waiting to be solved better, if anyone wants to take it on.

        Upon rereading the original question, your solution seems far closer than my suggestion. Copying a Perl installation is conveniently possible on Windows by simply copying the Perl directories. The autobundle would require reinstalling all modules, preferrably through CPAN, which is feasible for extensions without an XS component and harder for extensions that require an external library (such as many DBDrivers), so copying is the far easier approach indeed.