The Comprehensive Perl Archive Network (CPAN)

Perl offers additional modules to expand your development environment even further. These modules are contained in the CPAN.

What Is It?

The Comprehensive Perl Archive Network—called CPAN—is a large collection of Perl documentation and software. This software is contributed by volunteers who've written modules, programs, and documentation that they want to contribute to the Perl Community.

The list of modules available in CPAN is extensive. At the time of this writing, CPAN is approximately four years old, and more than 3,500 modules are available for installation. The modules cover a wide range of programming problems. Table 16.1 provides a short list to give you a taste of what's in CPAN.

The most important point to remember is that, for most problems, a module is already available for solving that problem at least partially. These solutions in CPAN have been coded, tested, and the code reviewed by many programmers for completeness and correctness.

Table 16.1. Modules in CPAN
TkGraphical interface for Perl programs. Specific toolkit modules are available for accessing specialty graphic libraries such as the Win32 API, Gtk, Gnome, Qt, or the X11 toolkit.
Net::*Networking modules. Interfaces for Mail, Telnet, IRC, LDAP, and 40+ others.
Math::*More than 30 modules for such constructs as complex numbers, fast fourier transforms, matrix manipulation, and so on.
Date::*, Time::*Modules for converting dates/times into and out of various formats and doing manipulations on them.
Data::*, Tree::*Modules for manipulating data structures such as linked-lists and B-trees.
DBI::*Genericinterface to databases.
DBD::*Interface to commercial and free databases such as Oracle, Informix, Ingres, ODBC, Msql, Mysql, Sybase, and many others.
Term::*Fine control over text-mode screens such as DOS's Command window or UNIX xterms.
String::*, Text::*Dozens of modules for parsing text and formatting text.
CGI::*,Modules for producing, serving, fetching, and parsing Web pages.
URI::*, 
HTML::*, 
LWP::* 
GD, Graphics::*, Image::*Modules for manipulating graphics and images
Win32::*, Win32API::*Modules for manipulating Microsoft Windows

The modules in CPAN all are copyrighted by their respective authors, so you should read the README file that comes with each module to see the terms under which the module can be used. Most often, the modules are distributed under the same terms as Perl itself, by the Artistic License or by the GNU General Public License.

CPAN is also the name of a standard module used to help install additional modules into your Perl installation. The CPAN module is documented in the Appendix, "Installing Modules."

Why Do People Contribute?

Over the last half century of computer programming, programmers have solved the same problems over and over again. Searching, sorting, communicating, reading, writing—these problems have actually changed very little since the 1950s. Some books on computer programming theory and management are still applicable after 20 or 30 years.

Solving the same problems over and over again is not always an interesting exercise and often results in inferior solutions; it's called "reinventing the wheel." And programmers are driven, ultimately, by solving interesting problems.

A typical frustrating situation for a programmer is to have spent a long time and a great deal of effort to solve a complex problem only to discover afterward that a simple and elegant solution was possible. This frustration leads to programmers seeking ways to share code with each other. Sharing has the interesting side effect of creating better code because other programmers may notice problems in your code that you do not.

The CPAN is an effort by the Perl Community to save itself from unnecessary work. The modules are there to keep you from having the frustrating experience of reinventing someone else's wheel.

The quality in most of the modules is also very good because the modules, as well as Perl, are developed under the Open Source model of production. When you install a module on your system, you automatically have the source code for the module. You can examine the source yourself and—based on the license—use portions of the source for your own programs, modify the source, and even contact the author with suggested changes.

On the surface, the idea of CPAN seems very communal, but the actual reasons that authors contribute to CPAN are widely varied. Sometimes they contribute to help others with similar problems. Sometimes they contribute for the sake of giving to a good cause. Sometimes they do so to help gain the respect and admiration of their peers—a powerful motivator. Whatever the reason, the end result is a very large body of work that you can use in your own programs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.204.201