CPAN modules安装 perl

How to install CPAN modules
Here are some recommended approaches to installing modules from CPAN, as with much of Perl there are several alternatives.

Some basics
Most Perl modules are written in Perl, some use XS (they are written in C) so require a C compiler (it’s easy to get this setup - don’t panic), see your OS of choice below to find out how to get the right compiler. Modules may have dependencies on other modules (almost always on CPAN) and cannot be installed without them (or without a specific version of them). It is worth throughly reading the documentation for the options below. Many modules on CPAN require a somewhat recent version of Perl (version 5.8 or above).

Quick start
Install cpanm to make installing other modules easier (you’ll thank us later). You need to type these commands into a Terminal emulator (Mac OS X, Win32, Linux)

cpan App::cpanminus
Now install any module you can find.

cpanm Module::Name
Tools
To help you install and manage your modules:

local::lib enables you to install modules into a specified directory, without requiring root or administrator access. See the bootstrapping technique for how to get started. You can create a directory per user/project/company and deploy to other servers, by copying the directory (as long as you are on the same operating system and perl version).

cpanm from App::cpanminus is a script to get, unpack, build and install modules from CPAN. It’s dependency free (can bootstrap itself) and requires zero configuration (install instructions). It automates the entire build process for the majority of modules on CPAN and works well with local::lib and perlbrew. Many experienced Perl developers use this as their tool of choice. Related tools: cpan-outdated, pm-uninstall, cpan-listchanges.

perlbrew from App::perlbrew is useful if your system perl is too old to support modern CPAN modules, or if it’s troublesome in other capacities (RedHat/CentOS are included in this list). perlbrew makes the process of installing a Perl in any directory much easier, so that you can work completely independently of any system Perl without needing root or administrator privileges. You can use multiple versions of Perl (maybe as you upgrade) across different projects. The separation from your system Perl makes server maintenance much easier and you more confident about how your project is setup. Currently Windows is not supported.

cpan from CPAN has been distributed with Perl since 1997 (5.004). It has many more options than cpanm, it is also much more verbose.

cpanp from CPANPLUS had been distributed with Perl since 5.10 (2007) until 5.20 (2014). This offers even more options than cpanm or cpan and can be installed just like cpanminus.

Perl on Windows (Win32 and Win64)
Strawberry Perl is an open source binary distribution of Perl for the Windows operating system. It includes a compiler and pre-installed modules that offer the ability to install XS CPAN modules directly from CPAN. It also comes with lots of modules pre-installed, including cpanm.

ActiveState provide a binary distribution of Perl (for many platforms), as well as their own perl package manager (ppm). Some modules are not available as ppm’s or have reported errors on the ppm build system, this does not mean they do not work. You can use the cpan script to build modules from CPAN against ActiveState Perl.

Perl on Mac OSX
OSX comes with Perl pre-installed. in order to build and install your own modules you will need to install the “Command Line Tools for XCode” or “XCode” package - details on our ports page. Once you have done this you can use all of the tools mentioned above.

Perl on other Unix like OSs
Install ‘make’ through your package manager. You can then use all of the tools mentioned above.

Other tools
CPAN::Mini can provide you with a minimal mirror of CPAN (just the latest version of all modules). This makes working offline easy.

CPAN::Mini::Inject allows you to add your own modules to your local CPAN::Mini mirror of CPAN. So you can install and deploy your own modules through the same tools you use for CPAN modules.

Which modules should I use?
TaskTask::Kensho lists suggested best practice modules for a wide range of tasks. https://metacpan.org/ will let you search CPAN. You could also get involved with the community, ask on a mailing list or find your nearest Perl Mongers group.@TOC

摘自于: https://www.cpan.org/modules/INSTALL.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值