lamcro
lamcro

Reputation: 6251

How can I install Perl module without using CPAN.pm?

Is it possible?

Upvotes: 21

Views: 23692

Answers (10)

Telemachus
Telemachus

Reputation: 19705

If the problem is no root access, I would recommend looking at local::lib and also this webpage for CPAN.pm and non-root installation.

But to answer the question as asked, CPAN or CPANPLUS are helpful, but they aren't required. You can always do it the old-fashioned way as Leon says - though usually, it's easier not to.

Upvotes: 2

dagelf
dagelf

Reputation: 1729

If you're asking this because you're having problems with CPAN... you're probably running out of RAM that's why you can't use CPAN.

Maybe you don't have a swap file. Try this:

$ sudo su
# dd if=/dev/zero of=/swap bs=1M count=1k # create a 1GB file
# mkswap /swap
# swapon /swap

Otherwise... stop some services.

$ sudo service mysql stop
$ sudo service nginx stop

...And try again

$ cpan install CPAN
$ cpan install MIME::Lite::TT::HTML

Upvotes: -2

vyshak
vyshak

Reputation: 41

We can install all perl modules both from and even with your terminal in ubuntu. If you are using a ubuntu server then execute the following command , 'sudo apt-get install "perl_module"' The modules which you want just give the name in "perl_module" means If you want to install Apache2::Cookie it will be in "libapreq2" so you have to give like, "sudo apt-get install libapreq2"

Upvotes: 0

somebody
somebody

Reputation: 495

See here: How to install perl modules using CPAN without root

I have just set this up on a server without root access and CPAN does everything automatically.

But if you really wanna install a module without CPAN and you don't have root (assuming this since you don't wanna use CPAN), you can do it as follows

perl Makefile.PL PREFIX=$HOME
make
make install

You're gonna have to hunt down dependencies yourself so it's better to use CPAN.

Upvotes: 3

numberwhun
numberwhun

Reputation: 956

I, as others have would highly suggest using CPAN.pm. It is a breeze to use and can resolve any dependencies associated with the module you need automatically.

On the other hand, I would suggest that you read the perlmodinstall document over at perldoc as it gives details on other os' as well.

Regards,

Jeff

Upvotes: -2

Paul Tomblin
Paul Tomblin

Reputation: 182762

If you download the source code, it will generally have a Makefile.PL. You run "perl Makefile.PL; make; make test; make install" and it will build and install for you.

Obviously if you're not using CPAN.pm, you're going to have to deal with dependencies yourself.

Also, if the reason you can't use CPAN.pm is that you don't have permission to install into /usr/lib/perl, you can force CPAN.pm to install locally, but I forget how.

Upvotes: 7

Ben S
Ben S

Reputation: 69342

If the .pm file is pure Perl and doesn't need to be compiled you can just put it in your application's lib folder and use it as normal.

Upvotes: 1

rjh
rjh

Reputation: 50274

If you are using Red Hat (Fedora, CentOS), you should use RPM for Perl dependencies wherever possible. Perl packages are almost always named perl-Module-Name, e.g. perl-DBI, perl-Spreadsheet-WriteExcel, etc.

On Ubuntu the naming scheme is libmodule-name-perl.

Upvotes: 1

Morinar
Morinar

Reputation: 3540

If you are on a Linux box, a very large portion of the packages can usually be obtained using the built in package manager. For instance, on an Ubuntu system, if you want to install the PostgreSQL Perl module you'd simple do:

sudo apt-get install libpg-perl

You can see a list of the modules for Ubuntu here: http://packages.ubuntu.com/hardy/perl/

I find I can often guess at the names myself. Not sure if this helps at all, but for myself I often find this easier to use than CPAN as it does a lot better at resolving dependencies.

Upvotes: 4

Leon Timmermans
Leon Timmermans

Reputation: 30225

If you download the source code, and read the README file. This will probably tell you you should do

perl Makefile.PL
make
make test
make install

or

perl Build.PL
./Build
./Build test
./Build install

Upvotes: 34

Related Questions