Install the Perl CPAN Module

Source: Internet
Author: User

Original article link

References

CPAN mirror Configuration

CPAN tutorial

Perl 5 tutorial

 

Perl has added the concept of modules to the fifth edition to provide Object-Oriented Programming capabilities. This is the history of Perl.
. Since then, the majority of Free Software enthusiasts have developed a large number of powerful and well-conceived Perl modules, greatly
Extends the features of the Perl language. CPAN (Comprehensive Perl archive network) is a Perl module on the Internet.
The largest distribution center contains almost all of the Perl modules announced today.

Several major CPAN sites are:
China:Ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN
Http://cpan.qz.fj.cn/
Foreign countries:Http://www.cpan.org/
Http://www.perl.com/CPAN-local/

Here I will introduce how to install the Perl module on various platforms. Take DBI installation as an example.

1,Linux/Unix installation method:

There are two ways to install the Perl module in Linux/Unix: manual installation and automatic installation. The first method is to download from CPAN.
You need to manually compile and install the modules. The second method is to connect to the Internet.
The entire process of download, compilation, and installation.

A. Steps for manual installation:

Download the dbi-1.13.tar.gz compressed file dbi-1.13.tar.gz from cpan, and place it under/usr/local/src.
CD/usr/local/src
Decompress the file:
Tar xvzf DBI-1.13.tar.gz
A new DBI-1.13 directory is created.
CD DBI-1.13

Generate makefile:
Perl makefile. pl
Create a module
Make
Test Module
Make Test
If the test result reports "all test OK", you can install the compiled module with confidence. Before installing a module
Make sure that you have the write permission on the perl5 installation directory (usually obtained using the su command) and execute:
Make install

Now, writeProgramTry it.

#! /Usr/bin/perl-W
Use strict;
Use dBi;
..

The preceding steps are applicable to the vast majority of Perl modules in Linux/Unix. The installation methods of a few modules may be slightly different,
So you 'd better check the README or install in the installation directory first. In addition, the above process is for Dynamic Link Perl Compilation
(All preinstalled Perl in Linux are dynamically linked). If you are using a static link Perl, you need
The new module is statically linked to the Perl compiler and may need to be restarted.

B. Use the CPAN module for automatic installation:

Before installation, you must first connect to IOT platform and obtain the root permission.
Perl-mcpan-e Shell
When you run CPAN for the first time, you need to make some settings. If your machine is directly connected to the Internet (Dial-Up, leased line, etc .),
Just press enter to select a CPAN image site closest to you. For example
China free software libraryFtp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN. Otherwise, if your machine
After the firewall is located, you also need to set the FTP proxy or HTTP proxy.

Get help
CPAN> H

List all modules on CPAN
CPAN> m

Installation Module
CPAN> install DBI
The entire process from downloading to installing the DBI module is automatically completed.

Exit
CPAN> q

2. How to install Win32:

In Win32, we recommend that you use Perl for Win32 of ActiveState, that is, ActivePerl. The home page of ActivePerl is:
Http://www.activestate.com/. In Win32, it is best to use a Perl module specially customized for ActivePerl. Slave
The Perl module downloaded by CPAN cannot be used well in ActivePerl. Similar to the CPAN module, ActiveState is also developed
An Automatic Installation tool called ppm (Perl Package Manager ).

The most common installation method is:
First online
Start ppm under doscommand line
Ppm

Get help
Ppm> H

List all Perl modules on the ActiveState site.
Ppm> Search

Installation Module
Ppm> install DBI
The entire process from downloading to installing the DBI module is automatically completed.

Exit
Ppm> q

If your machine is located behind the firewall and accesses the Internet through the HTTP proxy, you can use the following method.

For earlier versions of ActivePerl Based on Perl 5.005 (versions earlier than ActivePerl 522, excluding ActivePerl 522 ),
Http://www.ActiveState.com/ppmpackages/5.005/zips/Download your local perl, for example, dbi.zip.
Decompress the package in C:/temp/DBI.
CD/temp/DBI
PPM install DBI. PPD

The latest ActivePerl version based on Perl 5.6 (ActivePerl 613 and later) has a slightly different installation method. Security
Install Microsoft Windows installer before installing ActivePerl 613.
Download Windows Installer from here:
Http://activestate.com/download/contrib/Microsoft/9x/InstMsi.exe
ActivePerl 613 download from here:
Http://activestate.com/download/... ePerl-5.6.0.613.msi

For the ActivePerl version based on Perl 5.6
Http://www.activestate.com/PPMPackages/5.6/
Download the installation Description file of the Perl module, such as DBI. PPD.
Connect to IOT platform before installing the module
PPM install DBI. PPD.

The preceding describes in detail how to install the Perl module on various platforms. Hope to help Chinese Perl fans
Use a large number of excellent Perl modules to avoid repetitive work, improve efficiency, and give full play to the powerful power of the Perl language.

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.