What's the easiest way to install a missing Perl module?

I get this mistake:

Can't locate Foo.pm in @INC

Is there a less complicated means to install it than downloading and install, untarring, making, etc?

218
2022-06-10 18:43:18
Source Share
Answers: 10

Otto made a good suggestion. This benefits Debian also, along with any kind of various other Debian by-product. The missing out on item is what to do when proper - cache search does not locate something.

$ sudo apt-get install dh-make-perl build-essential apt-file
$ sudo apt-file update

Then whenever you have an arbitrary module you desire to install:

$ cd ~/some/path
$ dh-make-perl --build --cpan Some::Random::Module
$ sudo dpkg -i libsome-random-module-perl-0.01-1_i386.deb

This will certainly offer you a deborah plan that you can install to get Some:: Random:: Module. Among the large advantages below is male web pages and also example manuscripts along with the module itself will certainly be positioned in your distro is area of selection. If the distro ever before brings out a main plan for a more recent variation of Some:: Random:: Module, it will instantly be mounted when you proper - get upgrade.

8
2022-06-27 17:21:27
Source

Lots of referral for CPAN.pm, which is wonderful, yet if you are making use of Perl 5.10 after that you've additionally obtained accessibility to CPANPLUS.pm which resembles CPAN.pm yet far better.

And also, certainly, it is readily available on CPAN for individuals still making use of older variations of Perl. Why not attempt:

$ cpan CPANPLUS
7
2022-06-25 05:12:12
Source

Also see Yes, even you can use CPAN. It demonstrates how you can make use of CPAN without having origin or sudo accessibility.

10
2022-06-10 21:19:37
Source

A number of individuals stated the cpan energy, yet it is greater than simply beginning a covering. Simply offer it the components that you intend to install and also allow it do it is job.

$prompt> cpan Foo::Bar

If you do not offer it any kind of debates it begins the CPAN.pm covering. This works with Unix, Mac, and also need to be simply great on Windows (specifically Strawberry Perl).

There are numerous various other points that you can do with the cpan device too. Below is a recap of the existing attributes (which could be more recent than the one that features CPAN.pm and also perl):

-a
Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.

-A module [ module ... ]
Shows the primary maintainers for the specified modules

-C module [ module ... ]
Show the Changes files for the specified modules

-D module [ module ... ]
Show the module details. This prints one line for each out-of-date module (meaning,
modules locally installed but have newer versions on CPAN). Each line has three columns:
module name, local version, and CPAN version.

-L author [ author ... ]
List the modules by the specified authors.

-h
Prints a help message.

-O
Show the out-of-date modules.

-r
Recompiles dynamically loaded modules with CPAN::Shell->recompile.

-v
Print the script version and CPAN.pm version.
16
2022-06-10 20:08:57
Source

I keep in mind some individuals recommending one run cpan under sudo. That made use of to be essential to install right into the system directory site, yet modern-day variations of the CPAN covering permit you to configure it to make use of sudo simply for mounting. This is much more secure, given that it suggests that examinations do not run as origin.

If you have an old CPAN covering, merely install the new cpan ("install CPAN") and also when you refill the covering, it needs to motivate you to set up these new instructions.

Nowadays, when I'm on a system with an old CPAN, the first point I do is upgrade the covering and also set it approximately do this so I can do a lot of my cpan job as a regular customer.

Additionally, I 'd highly recommend that Windows customers explore strawberry Perl. This is a variation of Perl that comes packaged with a pre - set up CPAN covering along with a compiler. It additionally consists of some tough - to - compile Perl components with their exterior C collection dependences, especially XML:: Parser. This suggests that you can do the very same point as every various other Perl customer when it involves mounting components, and also points often tend to "just work" a whole lot regularly.

29
2022-06-10 19:37:27
Source

2 manner ins which I recognize of:

USING PPM:

With Windows (ActivePerl) I've made use of ppm

from the command line type ppm. At the ppm punctual

ppm> install foo

or

ppm> search foo

to get a checklist of foo components readily available. Type aid for all the commands

USING CPAN:

you can additionally make use of CPAN similar to this ( * nix systems ):

perl -MCPAN -e 'shell'

obtains you a punctual

cpan>

at the punctual

cpan> install foo  (again to install the foo module)

type h to get a checklist of commands for cpan

4
2022-06-10 19:15:28
Source

On Windows with the ActiveState circulation of Perl, make use of the ppm command.

2
2022-06-10 19:14:32
Source

sudo perl -MCPAN -e 'install Foo'

15
2022-06-10 18:53:45
Source

If you get on Ubuntu and also you intend to install the pre - packaged perl module (as an example, geo:: ipfree) attempt this:

    $ apt-cache search perl geo::ipfree
    libgeo-ipfree-perl - A look up country of ip address Perl module

    $ sudo apt-get install libgeo-ipfree-perl
26
2022-06-10 18:53:16
Source

On Unix :

generally you start cpan in your covering:

$ cpan

and also type

install Chocolate::Belgian

or basically kind:

cpan Chocolate::Belgian

On Windows :

If you are making use of ActivePerl on Windows, the PPM (Perl Package Manager) has a lot of the very same capability as CPAN.pm.

Instance:

$ ppm¢ppm> search net-smtp¢ppm> install Net-SMTP-Multipart

see How do I install Perl modules? in the CPAN FAQ

Many circulations deliver a great deal of perl components as plans.

  • Debian/Ubuntu: apt-cache search 'perl$'
  • Arch Linux: pacman -Ss '^perl-'
  • Gentoo: group dev-perl

You need to constantly favor them as you gain from automated (protection) updates and also the convenience of elimination . This can be rather complicated with the cpan device itself.

For Gentoo there is a wonderful device called g-cpan which builds/installs the module from CPAN and also develops a Gentoo plan (ebuild) for you.

257
2022-06-10 18:52:38
Source