The Temple of Fu

code, systems and games

Archive for the ‘Perl’ Category

Slackware – Perl CPAN

with one comment

There really isn’t anything different from managing your Perl libraries with CPAN on Slackware than on any other Linux distribution, but these are my notes and you are welcome to them. :] My Slackware 13 install came with version v1.9205 of CPAN. CPAN is short for The Perl Archive Network and is the gateway to all things Perl, the canonical location for Perl code and modules

The Perl version that comes stock on your Linux distribution or your Windows install is hugely powerful, but in fact it just scratches the surface. Throughout the years, people have created Perl modules to accomplish very specific tasks so that you don’t need to rewrite the wheel to perform those same tasks. But these modules are not, by default, on your computer. They reside on the CPAN website at http://www.cpan.org. Often you can simply download the Perl code comprising the new module, and place that Perl code in the right place. But sometimes it requires a recompile.

When working with Linux, you can actually use Perl itself to download, make, test and install new modules. This interface is called CPAN.

To get a ‘shell’ into CPAN run this.
perl -MCPAN -e 'shell'

The first time you run it, it will want to be configured, answer yes to the following prompt if in a hurry and let it autoconfigure.

CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes]

After it is done you will be shown a prompt like this:
cpan>

You can upgrade CPAN at the prompt; this also shows an example of how to install something.
cpan>install Bundle::CPAN

You will get some output similar to this, answer yes to connecting to the internet. This will upgrade CPAN and can take a few minutes to complete so be patient. There will be a few questions you must answer so stay at the prompt and be ready, most of the time the default answers are OK to use. The safest bet is if you do not know how to answer one go with the default.
........
New CPAN.pm version (v1.9402) available.
[Currently running version is v1.9205]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
...............

Here is another example of installing.
cpan>install Tk

From that prompt you can get help with the help command:
cpan> h

Display Information
command argument description
a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules
i WORD or /REGEXP/ about anything of above
r NONE reinstall recommendations
ls AUTHOR about files in the author's directory

Download, Test, Make, Install...
get download
make make (implies get)
test MODULES, make test (implies make)
install DISTS, BUNDLES make install (implies test)
clean make clean
look open subshell in these dists' directories
readme display these dists' README files

Other
h,? display this menu ! perl-code eval a perl command
o conf [opt] set and query options q quit the cpan shell
reload cpan load CPAN.pm again reload index load newer indices
autobundle Snapshot force cmd unconditionally do cmd
cpan>

To leave the prompt simply type exit
cpan> exit

Hope this helps someone!

Resources:
http://www.troubleshooters.com/codecorn/littperl/perlcpan.htm

Written by lordfu

January 23, 2010 at 4:15 pm

Posted in Perl, Slackware