Chapter 4
Listing 4 3. Makefile.PL Generated by h2xs
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => Data::Counter ,
VERSION_FROM => Counter.pm , # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => Counter.pm , # retrieve abstract from modul
AUTHOR => A. U. Thor ) : ()),
);
WriteMakefile() employs the named parameter style discussed in Chapter 3
using the parameters NAME, VERSION_FROM, PREREQ_PM, ABSTRACT_FROM, and AUTHOR. The
first parameter, NAME, is the name of your module. The second parameter here is
VERSION_FROM, which tells ExtUtils::MakeMaker where to look for the $VERSION
setting. This is necessary because a module distribution may have more than one
module. I will discuss multimodule distributions in depth later in the chapter.
The next parameter, PREREQ_PM, is initially empty, but is important enough that
h2xs includes it as a reminder. PREREQ_PM specifies your module's dependencies. By
including information on which other modules your module uses, you allow
the CPAN module to do its job much better. For example, if Data::Counter uses
CGI::Application, I would change the PREREQ_PM line to read as follows:
PREREQ_PM => { CGI::Application => 0 },
The keys of the PREREQ_PM hash are module names, and the values are version num
bers. By specifying a version number of zero, I'm telling ExtUtils::MakeMaker that
I need some version of CGI::Application installed, but I don't care which one. To
specify that I need at least version 1.3 installed, I would use this setting:
PREREQ_PM => { CGI::Application => 1.3 },
Now when a user tries to install Data::Counter using the CPAN module,
CGI::Application will be automatically installed. Using PREREQ_PM prevents users
from discovering a dependency when they try to use the module by advising them
when the module is installed. This ensures that the system is not cluttered with
half working code.
106
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved