FAQ
If anyone is wondering about what this mysterious line means:

$ sudo perl -MCPAN -e shell

Here is my basic understanding. This part:

perl -MCPAN -e shell

executes a perl program. The -e flag tells the perl command to execute the
line of code immediately following the -e flag. Here is an example:

$ perl -e 'print "hi\n";'

In that example, the outer quotes are necessary because on the command line
a space would terminate what the -e flag sees as its argument. Because perl
acolytes usually execute programs with use warnings, you can accomplish that
on the command line with the -w flag:

$ perl -w -e 'print "hi\n";'

Then if your single line of code after the -e flag has any errors in it,
they will be reported on the command line.

Therefore, this command:

$ perl -e shell

tells perl to execute the one line program that consists of the single line:
shell, which is a function call (in perl you don't always have to include
the parentheses like this: shell()).

This command:

$perl -MCPAN -e shell

uses the -M flag, and the -M flag tells the perl command to add the
following to the one line program (specified after the -e flag):

use CPAN;

which imports the CPAN module (yes, now the program has grown to two lines).
Importing the CPAN module allows the one line program to call functions
defined in the CPAN module. shell is a function defined in the CPAN module.

Finally, the leading sudo:

$ sudo perl -MCPAN -e shell

gives the program read/write/execute privileges of the administrator of your
computer, which is you if it's your computer. That allows the shell
function to install modules in system locations, like usr/local/bin, which a
program executing on your computer wouldn't normally have access to.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
groupcpan-discuss @
categoriesperl
postedNov 11, '09 at 4:06p
activeNov 15, '09 at 9:07a
posts5
users2
websitecpan.org

2 users in discussion

7: 4 posts Andreas J. Koenig: 1 post

People

Translate

site design / logo © 2022 Grokbase