ReadLine in Perl on Ubuntu


Update July 2012: A more robust solution, from within the cpan program, is: install Bundle::CPAN

A common Perl module, ReadLine is especially handy when running the cpan program to install other modules, as it lets you up-arrow through previous commands, edit your command with the arrows and so on.

At least on Ubuntu 10.10 ... CPAN will not install it. You get this error:

cpan> <span style="text-decoration: underline;">install Term::ReadLine</span>
Running install for module 'Term::ReadLine'
CPAN: Data::Dumper loaded ok (v2.124)
'YAML' not installed, falling back to Data::Dumper and Storable to read prefs '/home/luser/.cpan/prefs'
The most recent version "1.05" of the module "Term::ReadLine"
is part of the perl-5.12.2 distribution. To install that, you need to run
 force install Term::ReadLine   --or--
 install J/JE/JESSE/perl-5.12.2.tar.gz
Running make test
 Can't test without successful make
Running make install
 Make had returned bad status, install seems impossible
Failed during this command:
 JESSE/perl-5.12.2.tar.gz                     : make NO isa perl

(typed text is underlined.)

The proper Ubuntu way to get ReadLine installed is to:

$ <span style="text-decoration: underline;">sudo apt-get install libterm-readline-gnu-perl </span>

You probably also want to install Term::ReadLine::Perl (and) Term::ReadKey

Alternately, use the single-command-line cpanm to install one or more Perl modules and all dependencies, like this:

$ <u>cpanm Term::ReadLine Term::ReadLine::Perl Term::ReadKey</u>

You might also check Racker Hacker's article on auotmatically installing CPAN dependencies without requiring confirmation. Note, this will not prevent modules like those in the Test suite from asking:

<em>{this module} </em>is just needed temporarily during building or testing.
Do you want to install it permanently? [yes]