Initial CPAN Configuration

I view Perl as a newbie. I want to try some CPAN modules. When I run the install command on the Osx console, CPAN requests a configuration with the following statement:

To install the modules you need to configure the local Perl library directory or increase your privileges. CPAN can help you load the local :: lib module or configure yourself to use 'sudo' (if available). You can also solve this problem manually if you need to customize your setup.

Which approach do you need? (Choose "local :: lib", "sudo" or "manual")

What is the difference between local::lib and sudo ? If I understand this well, he installs some modules locally on my computer. But I do not see the difference between the two configurations above.

+6
source share
2 answers

If you use sudo, CPAN will use root to install the libraries in a central location where all users on the computer can access files without any special configuration. If you use "local :: lib", it will create a library in your home directory and install the modules so that only the perl modules that were configured to search for the modules in your home directory will find the modules.

Perl uses the special @INC variable to search for module paths. Therefore, you can install the modules anywhere as long as you install @INC correctly before using them. This article explains the basics.

http://www.symkat.com/find-a-perl-modules-path

You can do all kinds of funny things with @INC ; one of my favorite hacks is to put a function pointer there and use custom perl code for search modules.

+8
source
Good question. When you use local::lib , you can install the modules through CPAN User specific in this directory. Suppose you choose sudo as your approach, you are installing global modules.

This is similar to installing Node.js through npm . When you install a module with npm install -g <Modul> , its global is installed, and you can use it everywhere. But with this -g flag, it is only available in your current directory.

About the same here, except that you choose the standard installation method for CPAN Modules.

+3
source

All Articles