Install all perl modules linux

How to install all perl modules at once in Ubuntu

If it does not take too much space (>5 GB or so), I would not mind having them. I work behind a proxy, so setting up an automatic installer is hard, and hand-updating modules every now and then is just too much hassle.

3 Answers 3

Instead of installing everything, why not use CPAN::Mini to get them all on your local machine. Then you can install the ones you need when you need them.

might want to add something about using Perlbrew, instead of messing with the system perl. It doesn’t take much to hose your system mucking with it.

As others have said, you probably don’t want to.

  • Many modules are updated more frequently on CPAN than the Ubuntu repos
  • Some modules aren’t in the repos at all.
  • Many modules will have dependencies you don’t need.
  • If you ever need more than one environment, it’s a problem (although to be fair, this is generally a much rarer occurrence with perl than with other ecosystems).
  • perlbrew and cpanm are lovely and don’t require `sudo
  • It’s not a replacement for proper dependency management as if you ever have a distro upgrade, not all packages may be provided next time.

. however, if you’re determined, a very straightforward way would be to look at the output of

sudo apt-get search perl | sed -e 's/ - .*//' 

. and if it’s to your liking, run

sudo apt-get search perl | sed -e 's/ - .*//' | xargs sudo apt-get install 

Personally, I’d probably stick a | egrep ‘-perl’ | in there, too before the xargs , as you might get hits based on the description that don’t represent actual perl modules.

Источник

How to Install Perl Modules Using CPAN on CentOS 8

The Comprehensive Perl Archive Network (CPAN in short) is a popular central repository of currently 188,714 Perl modules in 40,986 distributions. It is a single location where you can find, download and install any of the incredible (and still growing) collection of Perl libraries.

It has 25,000 modules available and it is mirrored on servers around the world. It also supports automated testing: cross-platform and on multiple versions of Perl, and bug tracking for every library. Also, you can search it using various sites on the web, which offer tools such as grep, version-to-version diff as well as documentation.

Читайте также:  Linux halt vs shutdown

The CPAN Perl module is a core module that allows you to query, download, build and install Perl modules and extensions from CPAN sites. It has been distributed with Perl since 1997 (5.004). It includes some primitive searching capabilities and supports named and versioned bundles of modules.

In this article, you will learn how to install Perl and Perl modules in CentOS 8 using CPAN.

How to Install Perl CPAN Module in CentOS 8

Before you can use CPAN, you need to install the Perl-CPAN package, using the DNF package manager as shown.

Install Perl CPAN in CentOS 8

Note: Although most Perl modules are written in Perl, some use XS – they are written in C and so require a C compiler which is included in the Development Tools package.

Let’s install the Development Tools package as shown.

# dnf install "@Development Tools"

Install Development Tools in CentOS 8

How to Install Perl Modules Using CPAN

To install Perl modules using CPAN, you need to use the cpan command-line utility. You can either run cpan with arguments from the command-line interface, for example, to install a module (e.g Geo::IP) use the -i flag as shown.

# cpan -i Geo::IP OR # cpan Geo::IP

When you run cpan for the first time, it requires configuration as shown in the screenshot below. For this guide, we will enter yes to configure it automatically. If you enter no , the configuration script will take you through a series of questions to configure it.

Configure CPAN Automatically

The following screenshot shows the module Geo::IP has been installed on the system.

Perl Module Geo::IP Installed

Alternatively, you can run a cpan without arguments to start CPAN.pm shell. Then use the install sub-command to install a module (e.g Log::Log4perl) as shown.

# cpan cpan[1]> install Log::Log4perl

Install Perl Modules Using CPAN

How to List Installed Perl Modules and Versions

To list all installed Perl modules with their versions, use the -l flag as shown.

List Installed Perl Modules

How to Search a Perl Module Using CPAN

To search a module, open the cpan shell and use the m flag as shown.

# cpan cpan[1]> m Net::Telnet cpan[1]> m HTML::Template

Search Perl Modules Using CPAN

For more information, read the cpan manual entry page or get help from the CPAN shell using the help command.

# man cpan OR # cpan cpan[1]> help

How to Install Perl Modules Using CPANM

App::cpanminus(cpanm) is another popular module used to download, unpack, build and install modules from CPAN. To get it working on your system, install the App::cpanminus module as shown.

Install CPANM Module

You can install a module using cpanm as shown.

Install Perl Module Using CPANM

How to Install Perl Modules from Github

cpanm supports the installation of Perl modules directly from Github. For example, to install the Starman – a high-performance preforking Perl PSGI web server, run the following command.

# cpanm git://github.com/miyagawa/Starman.git

Install Perl Modules from Github

For more usage options, see the cpanm man page.

Читайте также:  Linux python конкретной версии

CPAN is a single location where you can find, download and install Perl modules; it currently has 192,207 Perl modules in 41,002 distributions. If you have any queries, share them with us via the feedback form below.

Источник

How to Install Perl Modules

Installing perl modules can be troublesome, especially when you’re not a ROOT user. After a lot of “pain”, I decide to document the two ways to install perl modules (it’s not my creation, just for a memo).

Check installed

# system perl
$ which perl
/usr/bin/perl
$ perl -e ‘use DBD::Oracle; print $DBD::Oracle::VERSION;’
Can’t locate DBD/Oracle.pm in @INC (@INC contains: /home/niuyw/software/perl.5.24.0/lib/site_perl/5.24.0/x86_64-linux /home/software/lib64/perl5 /home/software/share/perl5/ /home/software/vcftools-0.1.15/src/perl /home/niuyw/bin/perl_lib/share/perl5 /home/software/lib64/perl5 /home/software/share/perl5/ /home/software/vcftools-0.1.15/src/perl /home/niuyw/bin/perl_lib/share/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at -e line 1.

# perl installed under my own dirctory
$ ~/software/perl.5.24.0/bin/perl -e ‘use DBD::Oracle; print $DBD::Oracle::VERSION;’
Can’t locate DBD/Oracle.pm in @INC (you may need to install the DBD::Oracle module) (@INC contains: /home/niuyw/software/perl.5.24.0/lib/site_perl/5.24.0/x86_64-linux /home/software/lib64/perl5 /home/software/share/perl5/ /home/software/vcftools-0.1.15/src/perl /home/niuyw/bin/perl_lib/share/perl5 /home/software/lib64/perl5 /home/software/share/perl5/ /home/software/vcftools-0.1.15/src/perl /home/niuyw/bin/perl_lib/share/perl5 /home/niuyw/software/perl.5.24.0/lib/site_perl/5.24.0/x86_64-linux /home/niuyw/software/perl.5.24.0/lib/site_perl/5.24.0 /home/niuyw/software/perl.5.24.0/lib/5.24.0/x86_64-linux /home/niuyw/software/perl.5.24.0/lib/5.24.0 .) at -e line 1.
BEGIN failed—compilation aborted at -e line 1.

# if the module has been installed
$ ~/software/perl.5.24.0/bin/perl -e ‘use URI::Escape; print $URI::Escape::VERSION;\n’
3.31

Scenario 1: you’re a ROOT user OR use your own perl

Use cpan -i module_name

$ ~/software/perl.5.24.0/bin/cpan -i Net::Server

Use perl -MCPAN -e shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$ ~/software/perl.5.24.0/bin/perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell — CPAN exploration and modules installation (v2.16)
Enter ‘h’ for help.

cpan[1]> h

Display Information (ver 2.16)
command argument description
a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules
i WORD or /REGEXP/ about any of the above
ls AUTHOR or GLOB about files in the author’s directory
(with WORD being a module, bundle or author name or a distribution
name of the form AUTHOR/DISTRIBUTION)

Download, Test, Make, Install.
get download clean make clean
make make (implies get) look open subshell in dist directory
test make test (implies make) readme display these README files
install make install (implies test) perldoc display POD documentation

Upgrade installed modules
r WORDs or /REGEXP/ or NONE report updates for some/matching/all
upgrade WORDs or /REGEXP/ or NONE upgrade some/matching/all modules

Pragmas
force CMD try hard to do command fforce CMD try harder
notest CMD skip testing

Other
h,? display this menu ! perl-code eval a perl command
o conf [opt] set and query options q quit the cpan shell
reload cpan load CPAN.pm again reload index load newer indices
autobundle Snapshot recent latest CPAN uploads

# search modules using keyword
cpan[2]> i /scws/
Distribution XUERON/Text-Scws-0.01.tar.gz
Module < Text::Scws (XUERON/Text-Scws-0.01.tar.gz)
2 items found

# install modules
cpan[3]> install Net::Server
Net::Server is up to date (2.009).

# quit
cpan[5]> q/quit/exit

Scenario 2: you’re a common user but want to use the system perl

Install packages from source

mkdir -p /home/niuyw/bin/perl_lib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ tar zxf Capture-Tiny-0.46.tar.gz && cd Capture-Tiny-0.46
$ which perl
/usr/bin/perl

Читайте также:  Arch linux update all

# specify the path to install
$ perl Makefile.PL PREFIX=/home/niuyw/bin/perl_lib
Checking if your kit is complete.
Looks good
Generating a Unix-style Makefile
Writing Makefile for Capture::Tiny
Writing MYMETA.yml and MYMETA.json

$ make && make install
cp lib/Capture/Tiny.pm blib/lib/Capture/Tiny.pm
Manifying 1 pod document
Manifying 1 pod document
Appending installation info to /home/niuyw/bin/perl_lib/lib64/perl5/perllocal.pod

$ perl -e ‘use Capture::Tiny; print $Capture::Tiny::VERSION;’
0.46
export PERL5LIB=$PERL5LIB:/home/niuyw/bin/perl_lib/share/perl5:/home/niuyw/bin/perl_lib/lib64/perl5

Use cpanm

# download
$ wget https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7044.tar.gz

# install
$ tar zxf App-cpanminus-1.7044.tar.gz
$ cd App-cpanminus-1.7044
$ perl Makefile.PL PREFIX=/home/niuyw/bin/perl_lib
$ make && make install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$ ~/bin/perl_lib/bin/cpanm -h
Usage: cpanm [options] Module [. ]

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 force install
-n,—notest Do not run unit tests
—test-only Run tests only, do not install
-S,—sudo sudo to run install commands
—installdeps Only install dependencies
—showdeps Only display direct dependencies
—reinstall 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
-M,—from Use only this mirror base URL and its index file
—prompt 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
—self-contained Install all non-core modules, even if they’re already installed.
—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
-U,—uninstall Uninstalls the modules (EXPERIMENTAL)
-V,—version Displays software version

Examples:

cpanm Test::More # install Test::More
cpanm MIYAGAWA/Plack-0.99_05.tar.gz # full distribution path
cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz # install from URL
cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz # install from a local file
cpanm —interactive Task::Kensho # Configure interactively
cpanm . # install from local directory
cpanm —installdeps . # install all the deps for the current directory
cpanm -L extlib Plack # install Plack and all non-core deps into extlib
cpanm —mirror http://cpan.cpantesters.org/ DBI # use the fast-syncing mirror
cpanm -M https://cpan.metacpan.org App::perlbrew # use only this secure mirror and its index

You can also specify the default options in PERL_CPANM_OPT environment variable in the shell rc:

export PERL_CPANM_OPT=»—prompt —reinstall -l ~/perl —mirror http://cpan.cpantesters.org»

Type `man cpanm` or `perldoc cpanm` for the more detailed explanation of the options.
~/bin/perl_lib/bin/cpanm -l /home/niuyw/bin/perl_lib Log::Log4perl Math::CDF

Footnote

Change log

  • 20180413: create the note
  • 20180414: change the setting of PERL5LIB
  • 20190402: add the section “use cpanm”

Источник

Оцените статью
Adblock
detector