4

I'm currently running bash via Cygwin on Windows, and I've come across two different ways to install a Perl module

cpan Name::Module

and

perl -MCPAN -e shell

install Name::Module

What's the difference between these two methods, and do they offer any advantages or disadvantages over the other?

2 Answers 2

7

cpan installs for the perl in the shebang (#!) line of the cpan file.

When someone has more than one perl installed on a machine, they sometimes run the wrong copy of cpan, and thus end up installing modules for the wrong instance of perl.

One solution to that would be to specify the full path to the correct cpan file.

perl -MCPAN -e shell is the other solution. It allows you to explicitly specify the install of perl for which you want the modules to be installed.

2

cpan on Windows just calls App::Cpan->run( @ARGV ), which should give you the same shell as the other command, maybe with other settings active. But I think it's the same. So you could use both. I prefer just cpan and then do install Name::Module, since I tend to look if it's installed before and which version in the cpan shell beforehand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.