Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CPAN install module problem

1,974 views
Skip to first unread message

Howa

unread,
Feb 28, 2009, 12:03:45 AM2/28/09
to begi...@perl.org
Hi,

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?

Thanks


Chas. Owens

unread,
Mar 1, 2009, 5:02:47 PM3/1/09
to howa, begi...@perl.org
On Sat, Feb 28, 2009 at 00:03, howa <howa...@gmail.com> wrote:
snip

> perl -MCPAN -e "install Archive::Zip"
>>> Can't locate object method "install" via package "Archive::Zip" at -e line 1.
snip

Hmm, it looks like it is trying to use an indirect object method call
(that is it is trying to do this Archive::Zip->install() instead of
CPAN::install("Archive::Zip")). I wouldn't worry about it if I were
you, I would just use the new(ish) cpan command instead:

cpan Archive::Zip

This does the same thing

perl -MCPAN -e "install Archive:Zip"

should do.


--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Ron Bergin

unread,
Mar 1, 2009, 12:10:14 PM3/1/09
to begi...@perl.org

Since you're using double quotes, I assume that you're on Windows. I
suspect it has something to do with the way cmd is parsing the command
before passing it to perl.

If you enter the cpan shell and then issue install command, you can
avoid this problem.

e.g.,
this doesn't work, as you already know
C:\test>perl -MCPAN -e "install Archive::Zip"


Can't locate object method "install" via package "Archive::Zip" at -e
line 1.

this does work
C:\test>perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support enabled


cpan> install Archive::Zip
CPAN: Storable loaded ok
Going to read C:\Perl\cpan\Metadata
Database was generated on Sun, 01 Mar 2009 11:26:52 GMT
Running install for module Archive::Zip
Running make for A/AD/ADAMK/Archive-Zip-1.26.tar.gz
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/A/AD/ADAMK/Archive-Zip-1.26.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/A/AD/ADAMK/CHECKSUMS
CPAN: Compress::Zlib loaded ok
Checksum for C:\Perl\cpan\sources\authors\id\A\AD\ADAMK\Archive-
Zip-1.26.tar.gz ok
Scanning cache C:\Perl\cpan\build for sizes
Archive-Zip-1.26/
....
....
....

Howa

unread,
Mar 2, 2009, 11:06:55 AM3/2/09
to begi...@perl.org
On Mar 2, 1:10 am, r...@i.frys.com (Ron Bergin) wrote:
> Since you're using double quotes, I assume that you're on Windows.  I
> suspect it has something to do with the way cmd is parsing the command
> before passing it to perl.

no matter I use single or double quote (on Linux), both does not
work...

what I want to do is issue the commands in a sh for job automation. I
don't want to enter the cpan shell and type onstall every time...

Rob Dixon

unread,
Mar 2, 2009, 9:37:47 PM3/2/09
to Perl Beginners, howa

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

0 new messages