0

When looking at Cpanminus, I saw that one way to install it is the following:

curl -L https://cpanmin.us | perl - App::cpanminus

The first part downloads a file from the URL which can be interpreted by the Perl interpreter, and then pipes it to Perl. I can't figure out what the single dash argument is doing, though.

For that matter I'm not totally sure what the second argument is doing (why would Cpanminus need to know its own name?), but at least it looks less mysterious.

Stephen
  • 8,508
  • 12
  • 56
  • 96

1 Answers1

3

The first non-option argument passed to perl is the name of the file to execute. - indicates STDIN. Therefore, the command has perl execute the output of curl -L https://cpanmin.us, passing App::cpanminus as an argument.

Since curl -L https://cpanmin.us returns a self-contained version of cpanm, the whole command effectively downloads cpanm and uses it to install cpanm (a part of App::cpanminus).

In other words,

curl -L https://cpanmin.us | perl - App::cpanminus

is roughly the same as

curl -L https://cpanmin.us >self_contained_cpanm
perl self_contained_cpanm App::cpanminus
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • 1
    ... which, in turn, runs the cpanminus with the argument App::cpanminus, so it installs the library App:cpanminus, which provides cpanminus. – choroba Sep 25 '17 at 22:04