tutorial on modifying the default source for Cpan Mirror in Linux

Source: Internet
Author: User
Tags commit aliyun

A quick way to install many of the module files under Perl is to use the CPAN tool. The default CPAN shell uses the source of the cpan.org, which is very slow to use at home. If the replacement for domestic such as Ali or NetEase, such as the source of the company, the speed will be significantly improved. The modification method is as follows:

1, execute CPAN command to confirm the existence of this command

If you are prompted to locate the command after the CPAN is executed, you can either Perl-cpan or manually install the module by yum-y install.

[Root@localhost cpan]# CPAN
CPAN is the World-wide archive of Perl resources. It consists about
The around sites that all replicate the same contents globe. Many
Countries have at least one CPAN site already. The found on
CPAN are easily accessible with the CPAN.PM module. If you are want to use
CPAN.PM, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
Configuration, answer ' yes ' below.
If you are prefer to enter a dialog instead, you can answer ' no ' to this
Question and I ' ll let your configure in small steps one thing after the
Other. (Note:you can revisit this dialog anytime later by typing ' o
Conf Init ' at the CPAN prompt.)
Would You like me to configure as much as possible automatically? [Yes] Yes
............ Omitted
Commit:wrote '/usr/share/perl5/cpan/config.pm '
Terminal does not support addhistory.
CPAN Shell--cpan Exploration and modules installation (v1.9402)
Enter ' h ' for help.
The first execution will appear yes/no interface, input Yes will be automatically configured, enter no will allow manual configuration of some parameters. Here I have chosen Yes, and the configured profile is stored in/usr/share/perl5/cpan/config.pm.

2. View current Source Configuration

cpan[1]> o conf
$CPAN:: Config options from '/usr/share/perl5/cpan/config.pm ':
Commit [Commit changes to disk]
Defaults [Reload defaults from disk]
Help [short Help about ' o conf ' usage]
init [Interactive setting of all options]
Applypatch []
Auto_commit [0]
Build_cache [100]
Build_dir [/root/.cpan/build]
Build_dir_reuse [0]
Build_requires_install_policy [Ask/yes]
bzip2 [/USR/BIN/BZIP2]
Cache_metadata [1]
Check_sigs [0]
Cpan[2]> o-Conf urllist
Urllist
Type ' O conf ' to view all configuration items
The default source is not configured, that is, the official source used, so the source information is not found here.

3. Add source or remove source and submit

Cpan[3]> o-conf urllist push http://mirrors.aliyun.com/CPAN/
Use ' O conf commit ' to make the config permanent!
cpan[4]> o conf Commit
Commit:wrote '/usr/share/perl5/cpan/config.pm '
You can also add multiple sources at once:

Cpan[4]> o-conf urllist ftp://mirrors.sohu.com/CPAN/http://mirrors.163.com/cpan/
To remove a source, you can use the POP function, as follows:

Cpan[3]> o-conf urllist pop http://mirrors.163.com/cpan/ftp://mirrors.sohu.com/CPAN/
View current source information again

Cpan[5]> o-Conf urllist
Urllist
0 [http://mirrors.aliyun.com/CPAN/]
Type ' O conf ' to view all configuration items
You can also customize a configuration file for local users, which can be configured as root environment variable files (the principle is similar to profile and ~/.bash_profile)

# mkdir-p/root/.cpan/cpan/
# cp/usr/share/perl5/cpan/config.pm/root/.cpan/cpan/myconfig.pm

4. Re-initialize the configuration

If you are not satisfied with the current configuration of all cpan shells, you can also reinitialize the file by command, as follows:

cpan> o conf Init
In the end, if there is no extranet environment, or want to manually install the module, you can also refer to my previous blog CPAN module installation.

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.