|Problems? Is your data what you think it is?|
Writing Perl Modules for CPANby TStanley (Canon)
|on Aug 19, 2002 at 23:24 UTC||Need Help??|
Review Synopsis: Learn about the CPAN, and the techniques for writing a module worthy of the CPAN
The author starts off with a quick overview of the CPAN, describing its purpose, design, and history. He also describes how to browse, search, and install modules from the CPAN, using the CPAN module from the Perl distribution. He also makes note of the Perl Package Manager (PPM) from ActiveState, and gives short examples on how to use it.
The second chapter deals with the basic workings of modules, such as packages and symbol tables, and makes note of where the differences between Unix and Windows exist when applicable. He also covers the basics used in most common modules, such as tying scalars, hashes, and arrays, operator overloading, and the basics of object oriented programming.
The third chapter covers the design and implementation of modules. He starts off with the point of checking CPAN for existing modules. “CPAN is the greatest enabler of programmer laziness since the terminal!” He also makes an excellent point for documenting the module first. “If you can explain it in the docs, then there’s a good chance you’ll be able to code it”. Also covered in this chapter are parameter passing, exporting, and inheritance. He also makes use of the Class::Struct and Class::MethodMaker modules, which can be found on CPAN.
Chapter 4 touches on module installation as well as creation. For creating a basic template for a module, the author emphasizes the point of “Always begin with h2xs.” As he points out, it will save the programmer a lot of trouble, and he goes into some detail about its most commonly used options and the files that are produced from them.
Chapters 5 and 6 deal with actually submitting your module to CPAN, and some general guidelines and ideas, to help maintain the module once it is submitted. He discusses the Perl Authors Upload Server (PAUSE), how to obtain a CPAN ID, and registering your namespace. For the maintenance side of things, he covers the various methods used, such as email lists, emailing the author, using the diff command to generate patches, and refactoring of code. He also touches upon the Concurrent Version System (CVS), describing what it does, where it can be found, and giving some basic commands for its usage.
Chapter 7 is a showcase of some of the most well known (if not most used) modules found on CPAN. Listed in the number one spot is the CGI module, followed by DBI and Storable. Also listed are Net::FTP, LWP, XML::SAX, and Parse::RecDescent.
The next three chapters deal with programming with C and with XS. And both are subjects the author is obviously quite familiar and comfortable with. He covers the basics of the Perl C API, and works with the Gnome::MIME module in his chapter on XS. He also uses the Inline::C module to insert C code into the middle of a perl module.
The final chapter of the book deals with the CGI::Application module, which allows the programmer to create flexible code that can be used on multiple projects.
Overall, this book was very well written, with no obvious errors or typos, and the material was up-to-date. The only problem I had with this book, was that I felt not enough information regarding the creation of modules for Windows distribution was given out. However, the author did point out in the beginning of the book that it was primarily geared towards the Unix distributions.
I would heartily recommend this book to anyone who is considering releasing a module to CPAN.
Update:This review can also be found on http://perlhorizons.org