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.
- Wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-1.9600.tar.gz
- Tar zxvf CPAN-1.9600.tar.gz
- CD CPAN-1.9600
- Perl makefile. pl
- Make makefile
- Test makefile
- Make install makefile
Use CPAN for Installation
Method 1
# Export ftp_passive = 1
# Perl-mcpan-e Shell
- CPAN> install Bundle: CPAN # update
- CPAN> reload CPAN # reload
- 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
- # 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
- # Perl-mcpan-e Shell
- CPAN> O conf init # Initialize all configurations
- CPAN> reload CPAN # reload CPAN. This command reloads CPAN. PM.
- CPAN> O conf urllist unshift http://cpan.wenzk.com/# only change the image as the official image of China
- CPAN> O conf commit # submit and save
- CPAN> I yaml # view the information of the 'yaml' package
- CPAN> readme XML: libxm # displays information on online CPAN
- CPAN> reload index # reload the index
- CPAN> autobundle # autobundle command to display the latest CPAN upload information
- 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:
- CPAN-outdated | cpanm
How to package Perl into an execution File
1. Package
First install par: Packer
- CPAN par: Packer
You can use the following command to package
- PP-c-o get. pl
Start the filter to protect your Perl Program
- PP-F bleach-O hello. pl
Or
- PP-F bytecode-O hello. pl
Package as. Par
Does not contain core modules:
- PP-p-o script. Par script. pl
Including core modules:
- 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?
- 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
- 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
- Cpanm Module name
For example
- # Cpanm yaml
- Fetching http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/YAML-0.71.tar.gz... OK
- Refreshing ing YAML-0.71... OK
- Building and testing YAML-0.71 for yaml... OK
- 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
- # Cpanm -- Help
- Options:
- -V, -- verbose turns on Chatty output
- -Q, -- Quiet turns off the most output
- -- Interactive turns on interactive configure (required for task: modules)
- -F, -- Force install
- -N, -- notest do not run Unit Tests
- -S, -- sudo to run install commands
- -- Installdeps only install Dependencies
- -- Reinstall the distribution even if you already have the latest version installed
- -- Mirror specify the base URL for the mirror (e.g. http://cpan.cpantesters.org /)
- -- Mirror-only use the mirror's index file instead of the CPAN meta DB
- -- Prompt when Configure/build/test fails
- -L, -- local-lib specify the install base to install modules
- -L, -- local-Lib-contained specify the install base to install all non-core modules
- -- Auto-cleanup Number of days that cpanm's work directories expire in. defaults to 7
- Commands:
- -- Self-upgrade upgrades itself
- -- Info displays distribution info on CPAN
- -- Look opens the distribution with your shell
- -V, -- version displays Software Version