加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何安装Perl模块的一些方法

发布时间:2020-12-15 23:50:00 所属栏目:大数据 来源:网络整理
导读:如何安装Perl模块的一些方法 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 r

如何安装Perl模块的一些方法

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 now require a 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,?X Windows/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).

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 (March 2011) Win32/64 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?has been distributed with Perl since 2007 (5.009). This offers even more options than?cpanm?or?cpan.

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.?cpanm?can be installed by running?cpan App::cpanminus.

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 to 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?

Task::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 thecommunity,ask on a?mailing list?or find your nearest?Perl Mongers?group.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读