howa wrote:
> 
> Why sometimes I can use a command to install Perl module, e.g.
> 
> perl -MCPAN -e "install Digest::MD5"
> 
> But sometimes can't?
> 
> e.g.
> 
> perl -MCPAN -e "install Archive::Zip"
>>> Can't locate object method "install" via package "Archive::Zip" at -e line 
>>> 1.
> 
> 
> Are there any reason?

This is something I haven't noticed before:

  > perl -MCPAN -MO=Deparse -e "install Digest::MD5"
  install('Digest::MD5');
  -e syntax OK

  > perl -MCPAN -MO=Deparse -e "install Archive::Zip"
  'Archive::Zip'->install;
  -e syntax OK


The problem is that the CPAN module loads Archive::Zip itself, so that Perl then
recognizes the module name as a class instead of a simple bareword.

The easiest fix is to force the semantics by using parentheses:

  > perl -MCPAN -MO=Deparse -e "install(Digest::MD5)"

and

  > perl -MCPAN -MO=Deparse -e "install(Archive::Zip)"


both of which will work fine.

HTH,

Rob

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to