They Shoot Coders, Don't They? - Page 167
April 16, 2001
When the CPAN module installs a module successfully, it's a
greasy wheel, a magic carpet ride, a bag of chips. What better
way to impress a paramour than with a victorious series of Perl
module installs? But there's a dark side — sometimes, CPAN
chokes up a hairball and keels over. It may not be CPAN's fault
— some of these modules are simply hard to digest.
The vast majority of Perl modules are designed to be installed by
a basic set of steps. If you were manually installing a Perl
module from the command line, those steps are typically:
perl Makefile.PL parameters
make
make test
make install
And these are the steps that CPAN will execute for each module it
installs. Unfortunately, some module authors are rogues. They're
bad seeds, mavericks, the kind of coders you wouldn't want your
daughters hanging around with. They defy the rules, and so do
their modules. Some modules may require extra configuration
steps, such as manually editing a configuration file to specify
the locations of other programs or libraries in the system. To be
fair, sometimes the module authors haven't any choice, depending
on the nature of their module. There isn't anything CPAN can do
in these cases.
When CPAN fails to install a particular module, consider the
"look" command. You can let CPAN drop you into a sub-shell, where
you can view the module archive manually. From here you can
peruse any supporting documentation and/or manually edit any
configuration files it requires, or whatever other hoops you may
need to jump through. During the writing of this article, one of
the bundles we tried to install required the module "MD5". But
installation of this module choked in its testing phase.
cpan> look MD5
Running look for module MD5
Trying to open a subshell in the build directory...
Working directory is /home/lonelyone/.cpan/build/MD5-2.02
[lonelyone@badhost MD5-2.02]$
From here, we can nose around the files that make up MD5 and see
if there's anything we can do. Ultimately, we didn't find any
smoking gun. Typing 'exit' returns us to the CPAN shell. Here we
tried to use a little force .. literally:
cpan> force install MD5
MD5 still failed its self test, but CPAN installed it anyway.
Obedience is good.
CPAN Miscellany
It doesn't take a genius to figure out what commands CPAN
supports. A simple plea of 'help' reveals all. A few other
interesting CPAN commands include:
- r — The simple "r" command will analyze the version
numbers of all installed Perl modules in your system, and compare
them against the most recent versions on the CPAN site.
Differences are summarized, and you can decide whether to upgrade
any of your modules. Note that many modules apparently do not
have proper versioning, and this command appears to be present in
newer version of the CPAN module only.
- a — The "a" search lets you search for module authors
by name. Each module author is assigned a shorthand name, unique
from other authors. The obvious use for this is to see if any
Perl modules have your name, so that you can take credit for
their work at parties.
- ls — Once you've found a module author whose work you
cherish, supply their unique ID to "ls" and CPAN will try to list
other modules by that author.
Inside CPAN - Page 166
The Perl You Need to Know
A Private Stash (of modules) - Page 168
|