Two methods of installing Perl modules under Linux/unix share _perl

Source: Internet
Author: User

Method one, manual installation steps 

Download the DBI Module version 1.13 of the compressed file dbi-1.13.tar.gz from CPAN, assuming it is under/usr/local/src/.
Cd/usr/local/src
Unzip this 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
Building a module
Make
Test module
Make Test
If the test results report "All test OK", you can safely install the compiled module. Before you install a module, you must first
Make sure that you have writable permissions on the PERL5 installation directory (usually obtained with the SU command) and execute:
Make install

Now, write a program to try it.

#!/usr/bin/perl-w
Use strict;
Use DBI;
..

The above steps are suitable for most Perl modules under Linux/unix. There may be a few different ways of installing the modules, so it's a good idea to look at the Readme or install in the installation directory first. In addition, the above process is for dynamically linked Perl compilers (all Linux preinstalled Perl are dynamically linked), and if you are using a statically linked Perl, you need to link the new module statically to the Perl compiler and may need to reboot the machine.

method Two, use CPAN module to install automatically:

You need to be connected to the Internet before installing, and you need to get root permissions.
PERL-MCPAN-E Shell
When you first run CPAN, you need to make some settings, if your machine is directly connected with the Internet (dial-up, dedicated, etc.), then all the way to return to the line, just choose the last one from your nearest CPAN mirror site. For example, I chose the Chinese free Software library Ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN in China. Otherwise, if your machine is behind a firewall, you will also need to set up an FTP proxy or an HTTP proxy.

Get help
Cpan>h

List of all modules on CPAN
Cpan>m

Find a module on the CPAN by keyword:
Cpan[1]> i/scws/
Cpan:storable loaded OK (v2.20)
Going to read '/home/orisun/.cpan/metadata '
Database is generated on Sat, Nov 08:07:03 GMT
Distribution xueron/text-scws-0.01.tar.gz
Module Text::scws (xueron/text-scws-0.01.tar.gz)
2 Items found

Installing modules
Cpan>install DBI
Automates the entire process of DBI modules from downloading to installing.

Exit
Cpan>q

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.