ReadLine in Perl on Ubuntu

Tags:

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]

CPAN won't install Perl GD module on Ubuntu 9.04

Tags:

The 'cpan' command won't "install GD" as it complains that the GD library is not found. Although GD is installed in Ubuntu by default, you need the developer library. What you want instead is:

$ sudo apt-get install libgd-gd2-perl
$ perl
use GD;

(works!)

Bug, resolution, and patch to Net::LDAP::Server

Tags:

Dear Mr. Ranellucci,

I am writing an LDAP server using this module and have found that Evolution -- at least version 2.26.1 on Ubuntu -- transmits an abandonRequest after each searchRequest. Because there is no defined return value for an abandonRequest, the Perl module closes the socket and Evolution fails thereafter to communicate with the server.

The following patch resolves the bug, by properly checking whether the request -- NOT the response type -- is defined, and only hanging up in the event of an undefined request. The patch also only sends a response for defined response types -- of which abandonRequest has none.

With this patch, a server created with the Net::LDAP::Server module functions properly with Evolution.

I hope you will agree to incorporate this into the module and update CPAN accordingly.

Sincerely,

\/ William Lindley http://www.wlindley.com +1 480.947.6100

Patch follows. On my system, the appropriate file is:

/usr/local/share/perl/5.10.0/Net/LDAP/Server.pm

---begin--- ` 82,83c82,85 < my $respType = $respTypes{$reqType} < or return 1; # if no response type is present hangup the connection --- > if (!defined $reqType) { > return 1; # unknown request type - hangup connection > } > my $respType = $respTypes{$reqType}; 141,142c143,146 <

and now send the result to the client < print $socket

&encoderesult($mid, $respType, $result); --- > # and now send the result, if any, to the client > if (length($respType)) { > print $socket &encoderesult($mid, $respType, $result); > }`

---end---