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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.