20

Is it possible?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
lamcro
  • 6,069
  • 18
  • 57
  • 70

10 Answers10

34

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
Leon Timmermans
  • 30,029
  • 2
  • 61
  • 110
7

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
  • 1
    Or for Module::Build based distributions: perl Build.PL; perl Build; perl Build test; perl Build install – ysth Mar 05 '09 at 19:16
  • 2
    Running "o conf init" in the CPAN shell is the simplest way to reconfigure the whole thing. – Schwern Mar 05 '09 at 21:21
  • You can set the value for both makepl_arg and buildpl_arg to set any values you'd like at build time. See the CPAN.pm documentation. – brian d foy Mar 07 '09 at 20:05
4

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.

Morinar
  • 3,460
  • 8
  • 40
  • 58
3

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.

somebody
  • 495
  • 1
  • 7
  • 13
2

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.

Dmitry Verhoturov
  • 5,835
  • 2
  • 32
  • 39
Telemachus
  • 19,459
  • 7
  • 57
  • 79
  • You can also just run "o conf init" to redo the full CPAN configuration. – Schwern Mar 05 '09 at 21:20
  • So long as you have decent a compiler and access to make,you can bootstrap local::lib into your home directory and no root access is required at all. On the other hand, I've seen solaris boxes with pretty heavily locked-down compilers that limit the usefulness of this approach. – singingfish Mar 05 '09 at 23:18
1

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Ben S
  • 68,394
  • 30
  • 171
  • 212
  • To clarify, it should be your application's lib folder, not your system perl lib folder. Manually adding files to your system perl lib is just begging for dependency hell later on. – denkfaul Mar 05 '09 at 19:03
  • Good point, editted my answer. I've placed .pms in the perl libs folder, but I had developed them and they had no dependencies :D – Ben S Mar 05 '09 at 19:07
  • I have UserAgent.pm. I can just put it in the program's folder? What if it has dependencies? – lamcro Mar 05 '09 at 20:09
  • Then you'll have dependency hell, and have to hunt those down. See the installation notes for the library you're trying to install. Know that it's not recommended to do it this way. – Ben S Mar 05 '09 at 20:36
  • Don't tell the kids to do this please. You don't run the tests. You don't resolve dependencies. You don't know if the build process does anything to the .pm files. You don't know if there's other associated files (programs, configs, etc...). Don't do this unless you know what you're doing. – Schwern Mar 05 '09 at 21:18
  • As I said: "I had developed them and they had no dependencies" && "Know that it's not recommended to do it this way." – Ben S Mar 05 '09 at 21:21
1

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.

rjh
  • 49,276
  • 4
  • 56
  • 63
0

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"

vyshak
  • 41
  • 4
-2

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
dagelf
  • 1,468
  • 1
  • 14
  • 25
  • To the downvoter: Stop being so anal about the literal question, there is a question behind every question and in this case a valid one is: why isn't CPAN working, because does't tell you, it just fails and I've only seen it fail in low RAM and that happens most often if you don't have swap. – dagelf Nov 16 '17 at 16:46
-2

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

brian d foy
  • 129,424
  • 31
  • 207
  • 592
numberwhun
  • 956
  • 9
  • 7
  • It's not a breeze to use. Ever tried using cpan.pm on MinGW? It's extremely difficult. It runs out of memory and just fails, tries to install into directories you don't have permissions to, or just asks you too many hard questions you don't know the answers to. – Dmytro Sep 14 '16 at 23:35
  • I don't use Windows, and have never tried MiniGW as a result, but it sounds like it has its own issues. You may want to try running LInux in a VM with something like VirtualBox and see how it works for you there. – numberwhun Sep 23 '16 at 18:40