Phil Calvert wrote:
> I been trying to do "hack no. 8" from the O'Reilly book "Spidering Hacks" but keep getting hung-up.
>
> I enter the line "sudo perl -MCPAN -e 'install libwww-perl'" and things seem to go well for a while but then it gets stuck at:
>
> CPAN: Storable loaded ok
> Going to read /Users/thatsme/.cpan/Metadata
> Database was generated on Tue, 08 Jun 2004 19:34:06 GMT
> Warning: Cannot install 0, don't know what it is.
That's because your perl program (the bit in quotes following the -e) is: install libwww-perl;
The hyphen is being interpreted as a minus operator. Strings like libwww and perl are interpreted as being zero in numeric context, so that becomes 0 minus 0, which is 0. So you're telling it to install 0.
The fix is to fiddle a bit with the quoting to ensure that libwww-perl is interpreted as one string:
sudo perl -MCPAN -e 'install "libwww-perl"'
As sherm points out, without the extra quotes some modules install just fine, like Foo::Bar. There's no mathemagical operator in there, so perl assumes that you meant it as a string, and so Does The Right Thing.
If you'd turned on warnings and strictness like so: perl -MCPAN -Mstrict -Mwarnings -e ... you would have got some rather more useful error messages!
O'Reilly are good at putting errata on their web site, so you really should report this to them. I just checked and it doesn't appear that this one has been reported yet.
-- David Cantrell | Official London Perl Mongers Bad Influence
