Question

I'm taking a look into Perl as a total beginner. I want to try some CPAN modules. When I run an install command on my Osx console, CPAN asks for a configuration with the following statement :

To install modules, you need to configure a local Perl library directory or escalate your privileges. CPAN can help you by bootstrapping the local::lib module or by configuring itself to use 'sudo' (if available). You may also resolve this problem manually if you need to customize your setup.

What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')

What is the difference between local::lib and sudo options ? If I understand it well, it installs some modules locally on my computer. But I don't see any difference between the two config above.

Was it helpful?

Solution

If you use sudo, CPAN will use root to install the libraries in a central location where all users on the machine can access the files without any special configuration. If you use 'local::lib', it will create a library in your home directory and install the modules such that only perl programs that have been configured to look for modules in your home directory will find the modules.

Perl uses the special variable @INC to search for module paths. So you can install modules anywhere as long as you set @INC properly before you use them. This article explains the basics.

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

You can do all kinds of fun stuff with @INC; one of my favorite hacks it to put a function pointer in there and use custom perl code to lookup modules.

OTHER TIPS

Good question. When you use local::lib, you can install Modules via CPAN User specific in an given directory. Assume you choose sudo as approach, you install Modules global.

Its like installing Node.js via npm. When you install a module with npm install -g <Modul>, its global installed and you can use it everywhere. But withouth that -g flag, its just available inside your current directory.

Its about the same here, except that you choose the default way of installing CPAN Modules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top