16.1. There's More Than One Way To Do ItA distribution contains the module (or collection of related modules), plus all the support files required to document, test, ship, and install the module. While you could potentially construct all these files by hand, it's much simpler to use something to do it for you. In the beginning,[*] we had to create modules by hand. Soon after, the h2xs program grew into a module distribution creator, and that worked well for a while. Andy Lester created Module::Starter to make a better starter distribution, Jim Keenan created ExtUtils::ModuleMaker to make a better h2xs, and many other module creation systems popped up.[]
No matter which way we create our distribution or which tools we use, the process is the same. We run a Perl script that creates a file that pulls together all the information it needs to prepare and install the code. From there, we can test and install the modules. If we are using the traditional Makefile.PL, we start the installation with: $ perl Makefile.PL After that, we can test and install the module by telling make to perform the actions for those targets.[]
$ make all test install We may not want to use a Makefile.PL, though. It relies on the external program make, which, since it started life as a Unix tool, may not be available on all systems.[§] Ken Williams created the pure-Perl Module::Build system as a make replacement. Since we know that we must already have Perl installed and that Perl is portable, we can use it to install modules.
The Module::Build process looks the same, except that we start with a Build.PL file. $ perl Build.PL From there, we do the same sort of thing we did before. perl Build perl Build test perl Build install There are reasons to decide to use one or the other. The Makefile.PL method has been around for a long time, and it mostly works, except in odd cases. Its underpinnings depend on ExtUtils::Makemaker, which comes with Perl. Unfortunately, ExtUtils::Makemaker has become a bear to maintain, since it has to handle all of the special cases for the many, many systems on which Perl works. The Module::Build method is much newer, so it's still maturing and not as many people use it.[*] However, since Module::Build doesn't require an external program, it's easier for some people to use.
|