A Dark And Stormy Night ... - Page 165
April 16, 2001
You sit alone, at the keyboard, staring at the prompt:
[lonelyone@badhost]$
Friday night is here, and you're juiced up to script some Perl
(we're just kidding, of course, you are well-liked and popular
with all genders). It's a good idea, both for future reference
and future pickup lines, to know which version of Perl is
installed on this system:
[lonelyone@badhost]$ perl -v
This is perl, v5.6.1 built for i686-linux
Let's hustle to the farmer's market that is CPAN. To visit CPAN,
you'll need to use the CPAN module. Apropos for a farmer's
market, it looks like we might have the chicken and egg paradox
on our hands — you need a module to retrieve modules
— but in this case, the answer is "the chicken". The CPAN
module has been part of the standard Perl distribution for awhile
now. If the following command does not work, and thus CPAN is not
part of your ISP's old, crusty version of Perl, I would raise
hell.
perl -MCPAN -e shell
The above command will launch Perl with the CPAN module (the -M
argument), and execute (-e) the command 'shell'. This brings us
into the CPAN "interactive shell", a mini-environment for
executing CPAN-specific commands.
When CPAN runs for the first time, it will try to create a
configuration file. For most users, this will be ~yourhome/.cpan,
and a message to this effect appears in the welcome output:
/home/lonelyone/.cpan/CPAN/MyConfig.pm initialized.
Following the welcome text, we are given the chance to engage in
manual or automatic configuration. It's a good idea to say 'yes'
to manual configuration, especially because we want to build Perl
modules in our private home directory, rather than the Perl
installation tree. The value in square brackets following the
question is CPAN's default answer, which you can simply hit Enter
to accept, or else type your alternate choice.
Are you ready for manual configuration? [yes] yes
As you'll see between configuration questions, CPAN is very
talkative. Following more chatter, we're asked to confirm a local
directory for CPAN to work in — it needs a place to save
and build modules. Unless you have a strong objection, the
default is fine.
From here on in, we won't detail every question that the CPAN
interrogation asks, because there are many. Most of the time, we
choose the defaults. Below, let's go over the questions that need
specific, non-default responses:
Policy on building prerequisites (follow, ask or ignore)? [follow]
Some modules require other modules to be installed. If CPAN
detects that you need new or upgraded modules, it can
automatically retrieve and install them, or ask you for
permission for each prerequisite module. In many cases, "follow"
will work fine and save you the hassle of approving each
decision. However, there are cases where module dependencies
might contain mistakes, causing CPAN to go on a wild goose chase,
or down a path you'd rather not go down. The safe choice is
"ask", thus embracing you in the process.
Parameters for the 'perl Makefile.PL' command?
This is a very important configuration item. We want CPAN
to install Perl modules in a special place, not the Perl
installation tree. So the answer to this question is crucial.
Imagine that our home directory is ~lonelyone. Within, we've
created perl, for all our Perl stuff, and within that
modules, for just the module stuff. So, we'll want
~lonelyone/perl/modules to be where CPAN installs Perl
modules, and where Perl will look for these modules when we run
scripts out of there.
Your choice: []
PREFIX=~lonelyone/perl/modules LIB=~lonelyone/perl/modules
[The lines above are one line. It has been split for
formatting purposes.]
We've supplied two parameters, PREFIX and LIB. This will ensure
that CPAN builds modules in our home directory, and later we'll
see how to instruct Perl to find the modules there.
Continuing with the configuration questions (again, we choose
the defaults), eventually CPAN will ask you to choose some CPAN
sites. When you finally complete the interrogation, you'll land
at the CPAN shell prompt.
The Perl You Need to Know Part 23: CPAN, a Farmer's Market for Perl - Page 164
The Perl You Need to Know
Inside CPAN - Page 166
|