Introduction to CPAN use of Perl learning notes

Source: Internet
Author: User
Tags documentation install perl
This article mainly introduces the use of CPAN in Perl study notes.This article explains what is CPAN, the introduction of CPAN's directory role, the two methods of CPAN to install Perl Module, etc.

PANCPAN (Comprehensive Perl Archive Network: Comprehensive Perl Archive Network) is the central repository for finding anything related to Perl. It contains wisdom gathered from the entire Perl community: hundreds of Perl modules and scripts, documentation equivalent to several books, and the entire Perl distribution. If something is written in Perl and it is useful and free, then it is most likely on CPAN. CPAN has mirrors all over the world. You can find the mirror closest to you on the CPAN street sign at http://www.perl.com/CPAN. That street sign will remember which image you chose and you will automatically redirect to that image when you visit http://www.perl.com/CPAN/ (note the last slash). Alternatively, you can start at http://www.cpan.org. The interface of this station is different, but the data is the same.

Introduction to the use of CPAN in Perl study notes-
Authors

目录 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, then you can look in the authors / Lincoln_stein directory . If you don't know who wrote these modules, you can find them in the modules directory described below.

Doc

目录 This directory holds all styles of Perl documentation, including several different arrangements and formats of Perl's official man pages, such as text, HTML, PostScript, and Perl's own pod format.

Modules

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

Ports * This directory contains the source code, and sometimes there are some pre-built executable Perl port, mainly for operating systems that are not directly supported in the standard version, or some difficult compilers. scripts * This directory contains a small variety of 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. The Perl Power Tools project (Perl Universal Toolbox, PPT) is also placed here. The goal of PPT is to remake all Unix and tools in Perl. Most of the standards have been completed, and some less standard ones have also been completed.

Src

In this directory, you can find the source code of the standard Perl distribution. In fact, there are two standard Perl versions of the source code, one marked stable and the other devel. (The index page of this directory is explained in detail.) They are just links to the corresponding version. Earlier when we wrote these, stable.tar.gz was to perl-5.6.0.tar.gz (the usual solution is: if the second number of the version number is even, then it is the official version, if it is odd, Then it's a development version. The .tar.gz suffix sometimes is .tgz, indicating that it is a standard Internet format: GNU compressed tar archives, often called "tarball") symbolic links.

Install Perl Source

  code show as below:

$ Wget http://www.cpan.org/src/5.0/perl-5.18.2.tar.gz

$ Tar -xzf perl-5.18.2.tar.gz

$ Cd perl-5.18.2

$ ./Configure -des -Dprefix = $ HOME / localperl

$ Make

$ Make test

$ Make install

Install Perl's Module

Method 1: Manual installation

If the DBI module is installed and placed in the / home / Bird directory.

   code show as below:

$ Cd / home / Bird #Assuming this directory.

$ Tar xvzf DBI-1.13.tar.gz # Unzip

$ Cd DBI-1.13 #Enter the newly created directory

Per $ perl Makefile.PL #Generate Makefile

$ 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, then OK!

适宜 This method is suitable: when the installation package is ready. Most packages under Linux can be installed using this method! In special cases, you need to check the installation instructions.

Method 2: cpan installation

   code show as below:

Perl -MCPAN -e shell

Cpan> h #Get help

Cpan> m #Get module

Cpan [1]> i / DBI / #match search

Cpan> install DBI #Install the module

Cpan> q #Quit the installation

适宜 This method is suitable: the host is connected to the network without being walled!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.