How to install the Perl Module

Source: Internet
Author: User
Tags install perl

 Install with CPAN

1. My system is Debian. By default, only Perl-base is installed, that is, Perl can be used, but CPAN is not installed. Therefore, Perl is installed in the system.

    Aptitude install Perl

Install Perl-modules in addition. You can use the CPAN tool to install the Perl module.

The original method is to manually install the .tar.gz package of cpan.pdf from www.cpan.org, written by the buddy of CPAN modular andk.

  1. Wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-1.9600.tar.gz
  2. Tar zxvf CPAN-1.9600.tar.gz
  3. CD CPAN-1.9600
  4. Perl makefile. pl
  5. Make makefile
  6. Test makefile
  7. Make install makefile

Use CPAN for Installation

Method 1

# Export ftp_passive = 1

# Perl-mcpan-e Shell

  1. CPAN> install Bundle: CPAN # update
  2. CPAN> reload CPAN # reload
  3. CPAN> install TK # Install pm. Just add the module name with install.

Method 2

    # Expoort ftp_passive = 1
    # Perl-mcpan-e 'Install module name'

Method 3

  1. # CPAN Module name

Use of CPAN in Perl

CPAN command: download the software package corresponding to the get module and decompress the package. In Linux, the software package is. CPAN/sources/authors/ID/, and the decompressed package is. CPAN/build.

 

    # Export ftp_passive = 1

  1. # Perl-mcpan-e Shell
  2. CPAN> O conf init # Initialize all configurations
  3. CPAN> reload CPAN # reload CPAN. This command reloads CPAN. PM.
  4. CPAN> O conf urllist unshift http://cpan.wenzk.com/# only change the image as the official image of China
  5. CPAN> O conf commit # submit and save
  6. CPAN> I yaml # view the information of the 'yaml' package
  7. CPAN> readme XML: libxm # displays information on online CPAN
  8. CPAN> reload index # reload the index
  9. CPAN> autobundle # autobundle command to display the latest CPAN upload information
  10. CPAN> recent # Rencent command to display the recently uploaded Software Package

Query, delete, and update the Perl Module

1. Read the module documentation:

Perldoc module: Name

2. Check whether the module is installed:

Perl-mmodule: Name-E 0

3. Check whether the module is installed and where it is installed:

Perldoc-LM yaml

4. Delete the module and use the app: pmunintsall module to implement:

First install the app: pmuninstall
CPAN app: pmuninstall

Use the PM-uninstall Module name

5. Read the entire Perl document:

Perldoc Perl

Perldoc perltoc

Perldoc

6. Check which modules are installed on the machine:

Perl-mextutils: installed-Le 'print foreach extutils: installed-> New-> les le'

7. Check which modules are installed in Perl:
Perl-mmodule: corelist-Le 'print foreach module: corelist: find_modules'

Perldoc-l yourmodule

Perldoc-l CGI: carp

8. How can I know which Perl modules I have installed?

    Find 'perl-e' print "@ INC" ''-name' *. Ms'-print

9. query the location of a specified module:

    Perl-myaml-e 'print $ _. "=>". $ Inc {$ _}. "\ n" for keys % inc'

10. query the version of the currently used module:

    Perl-mmodule-e 'print $ module: version ;'

11. Install and update the latest modules
We often get old in many modules. We want to use the latest CPAN without a good control mechanism, so here we can use a module to accomplish the same function, called app :: cpanoutdated can be used to find the modules installed on the local machine, which can be updated and listed. If cpanm is used for installation, I will not discuss the installation method.

[Root @ Fukai ~] # CPAN-outdated
M/ml/mlehmann/AnyEvent-5.31.tar.gz
M/ml/mlehmann/AnyEvent-HTTP-2.03.tar.gz
N/NA/Naim/AnyEvent-HTTPBenchmark-0.09.tar.gz
P/Ph/phred/Apache-Reload-0.11.tar.gz
P/Ph/phred/Apache-SizeLimit-0.95.tar.gz
P/Ph/phred/Apache-Test-1.36.tar.gz
B/Bi/bingos/Archive-Extract-0.48.tar.gz
B/Bi/bingos/Archive-Tar-1.76.tar.gz
S/SM/smueller/Attribute-Handlers-0.88.tar.gz
S/SM/smueller/AutoLoader-5.71.tar.gz
F/FL/Flora/autouse-1.06.tar.gz
R/ru/rurban/B-C-1.29.tar.gz
R/ru/rurban/B-Debug-1.16.tar.gz
F/FL/Flora/B-Lint-1.12.tar.gz
R/rg/rgarcia/base-2.15.tar.gz
F/FL/Flora/bignum-0.25.tar.gz

We can directly pass it to cpanm for installation:

  1. CPAN-outdated | cpanm

How to package Perl into an execution File
 

1. Package

First install par: Packer

  1. CPAN par: Packer

You can use the following command to package

  1. PP-c-o get. pl

Start the filter to protect your Perl Program

  1. PP-F bleach-O hello. pl

Or

  1. PP-F bytecode-O hello. pl

 
Package as. Par
Does not contain core modules:

  1. PP-p-o script. Par script. pl

Including core modules:

  1. PP-B-p-o script. Par script. pl

Bleach filters are implemented by PAR, while bytecode filters are in standard perl format (supported by Perl 5.8.1 or later)

2. How can I check if something goes wrong?

  1. Scandeps. pl-v-e 'use yaml ;'

Check the dependency of all packages.

3. Floating Point exception
Most of the reason is that the GCC version is different. We recommend that you use the same operating system and number of digits.

Use cpanm for Installation

CPAN shell and cpanplus Problems
But in general, this is still a little troublesome. If the user does not have cpanplus, It is very troublesome to install this cpanplus. because it can run normally only by many other modules. This will increase the headache for users.

The CPAN shell of Perl itself is difficult to start and requires a large amount of content to be configured. For Beginners, as long as a Perl environment can be quickly developed, there is no need to waste time on this.
 

Advantages of cpanminus
Because of the above problems, Perl fans who are omnipotent always have various ways to make the problem simple. The following is a very simple method to install modules.

What's amazing about cpanminus. After downloading, you can use it directly without any other modules (when the module of Perl itself is: Build, extutils: makemaker and C compiler, this is what the system has ). It is not important to have root permissions. If it is not root, it will be automatically installed to the current user's directory.
 
 Installation of cpanminus
 

  1. Curl-l http://cpanmin.us | Perl-app: cpanminus

Installation is complete .... It's so easy, because it's just a file. In this example, after you download cpanm, you can directly use it to install the first software called app: cpanminus, which is actually its own.

Use of cpanminus

  1. Cpanm Module name

For example

  1. # Cpanm yaml
  2. Fetching http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/YAML-0.71.tar.gz... OK
  3. Refreshing ing YAML-0.71... OK
  4. Building and testing YAML-0.71 for yaml... OK
  5. Successfully reinstalled YAML-0.71

It's easy to use. You can also directly add the module name and remote module URL.

Attached with help

  1. # Cpanm -- Help
  2. Options:
  3. -V, -- verbose turns on Chatty output
  4. -Q, -- Quiet turns off the most output
  5. -- Interactive turns on interactive configure (required for task: modules)
  6. -F, -- Force install
  7. -N, -- notest do not run Unit Tests
  8. -S, -- sudo to run install commands
  9. -- Installdeps only install Dependencies
  10. -- Reinstall the distribution even if you already have the latest version installed
  11. -- Mirror specify the base URL for the mirror (e.g. http://cpan.cpantesters.org /)
  12. -- Mirror-only use the mirror's index file instead of the CPAN meta DB
  13. -- Prompt when Configure/build/test fails
  14. -L, -- local-lib specify the install base to install modules
  15. -L, -- local-Lib-contained specify the install base to install all non-core modules
  16. -- Auto-cleanup Number of days that cpanm's work directories expire in. defaults to 7
  17. Commands:
  18. -- Self-upgrade upgrades itself
  19. -- Info displays distribution info on CPAN
  20. -- Look opens the distribution with your shell
  21. -V, -- version displays Software Version
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.