Introduction to cpan in Perl learning notes


Cpan (Comprehensive Perl Archive Network) is the central repository for finding anything Perl related. It contains wisdom gathered from the entire Perl community: hundreds of Perl modules and scripts, documents equivalent to several books, and the entire Perl release. If something is written in Perl and it is useful and free, it is likely to be on cpan. Cpan has a mirror image all over the world. You can find it in Find the mirror closest to you on the cpan road sign. The road sign will remember which mirror you chose and you will visit it later (note the last slash) will automatically redirect to the image. In addition, you can also Start. The interface of this station is different, but the data is the same.

Introduction to cpan in Perl learning notes


This directory contains many subdirectories, one for each contributor. For example, if you want to find Lincoln Stein’s well written CGI modules (now part of the standard Perl version), and you happen to know that he wrote these modules, you can go to authors / Lincoln_ Look in the Stein directory. If you don’t know that he wrote these modules, you can find them in the modules directory described below.


This directory holds all styles of Perl documents, including several different permutations and formats of Perl’s official man pages, such as text, HTML, postscript, and Perl’s own pod format.


This directory contains modules written in Perl or a mixture of Perl and C.

ports   * This directory contains source code, and sometimes some pre compiled executable Perl porting, mainly for operating systems that are not directly supported in the Standard Version, or some compilers that are difficult to use. Scripts * this directory contains a small number of various Perl programs sent from all over the world. They can be used as stand-alone programs or as examples. At present, there are not many programs listed here, but over time, this area will become more and more abundant. Perl power tools project (Perl universal toolbox, PPT) is also placed here. The goal of PPT is to remake all UNIX and tools with Perl. Most of the standards have been completed, and some less standard ones have also been completed.


In this directory, you can find the source program of the standard Perl release. In fact, there are two standard Perl versions of the source program, one marked stable and the other devel. (the index pages of this directory are explained in detail.) they are only links to the corresponding versions. As early as we wrote this, stable.tar.gz is from perl-5.6.0.tar.gz (the usual scheme is: if the second number of the version number is even, it is the official version; if it is odd, it is the development version. Sometimes the suffix of. Tar.gz is. Tgz, indicating that it is a standard Internet format: GNU compressed tar archive, often called “tarball”) Symbolic links.

Install source for Perl

Copy codeThe code is as follows:

$  wget   
$  tar -xzf perl-5.18.2.tar.gz   
$  cd perl-5.18.2   
$  ./Configure -des -Dprefix=$HOME/localperl   
$  make   
$  make test   
$  make install   

Installing Perl’s module
Method 1: manual installation
If you install the DBI module, put it in the / home / bird directory.  

Copy codeThe code is as follows:

$ cd /home/Bird    # Suppose you put it in this directory.    
$tar xvzf dbi-1.13.tar.gz# decompression   
$ cd DBI-1.13   # Enter the newly created directory  
$Perl # generate makefile file   
$ make   # Build module   
$make test # test module    
$make install # compile module  
$write a test program as follows:  
#!/usr/bin/perl -w   
use strict;   
use DBI;   

Test whether the module is available. If no error is reported, it is OK!  


This method is suitable when the installation package is ready. Most packages under Linux can be installed in this way! In special cases, you need to query the installation instructions.
Method 2: cpan installation

Copy codeThe code is as follows:

perl -MCPAN -e shell   
cpan>h                  # Get help  
cpan>m                    # Acquisition module  
cpan[1]> i /DBI/        # Match lookup   
cpan>install DBI       # Installation module  
cpan>q                  # Exit installation  

This method is suitable: the host is connected to the network and is not blocked by the wall!