Hack #32. Manage Module Installations
Bundle up required modules to make installations easier.
Embracing the Perl way means taking advantage of the CPAN when possible. There are thousands of reusable, easily installable modules that do almost anything you can imagine—including making your coding life much easier and simpler.
Some day you'll have to distribute your software, upgrade Perl, or do something else that means that you can't rely on having all of your existing modules available. Never fear; just create a bundle that the CPAN module can use to install all of the necessary modules for you!
The Hack
The CPAN module doesn't only download and install modules. It can also give you a catalog of what you have installed on your system. The autobundle command takes this list and writes it to a bundle file—a very simple, mostly POD module that CPAN can use later (or elsewhere) to install necessary modules.
Tip
If you only support one application, you can use a technique such as in "Trace All Used Modules" [Hack #74] to figure out everything you need to install.
All you have to do is launch the shell, issue the autobundle command, and note where it creates the bundle file:
$cpancpan shell -- CPAN exploration and modules installation (v1.7601) ReadLine support enabled cpan>autobundle# time passes... Wrote bundle file /usr/src/.cpan/Bundle/Snapshot_2005_11_13_00.pm
Running the Hack
Copy or move the bundle file from its current location. Then when you upgrade or reinstall Perl, or when ...