Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #165291

Re: How to install Perl with readline support?

From David Christensen <dpchrist@holgerdanske.com>
Newsgroups linux.debian.user
Subject Re: How to install Perl with readline support?
Date 2016-03-12 18:40 +0100
Message-ID <rbVG9-19K-19@gated-at.bofh.it> (permalink)
References <rbV3s-BF-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 03/12/2016 08:54 AM, Kynn Jones wrote:
> I have been searching for the answer to the subject line's question
> for the last two hours.

On my Wheezy 7.9 box, Term::ReadLine is already installed.


RTFM Term::ReadLine, pasting the SYNOPSIS into a script, and running it:

     $ cat readline.pl
     use Term::ReadLine;
     my $term = Term::ReadLine->new('Simple Perl calc');
     my $prompt = "Enter your arithmetic expression: ";
     my $OUT = $term->OUT || \*STDOUT;
     while ( defined ($_ = $term->readline($prompt)) ) {
         my $res = eval($_);
         warn $@ if $@;
         print $OUT $res, "\n" unless $@;
         $term->addhistory($_) if /\S/;
     }

     $ perl readline.pl
     Enter your arithmetic expression: 1+1
     2
     Enter your arithmetic expression: ^[[A^C


History did not work on the second prompt.


 > I have [installed]
 >
 >      libreadline-dev
 >      libterm-readline-gnu-perl
 >      libterm-readline-perl-perl

RTFM Term::ReadLine indicates that a back end is needed. Either of the 
latter two you installed should be sufficient.


If I install:

     libterm-readline-perl-perl


And run the example again:

     $ perl readline.pl

     Enter your arithmetic expression: 1+1
     2

     Enter your arithmetic expression: 1+1
     2

     Enter your arithmetic expression:


History works, but there are extra blank lines between prompts and my 
terminal can get stuck in bold mode depending on how I exit (?).


David

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to install Perl with readline support? Kynn Jones <kynnjo@gmail.com> - 2016-03-12 18:00 +0100
  Re: How to install Perl with readline support? "John L. Cunningham" <djohngo@gmail.com> - 2016-03-12 18:10 +0100
    Re: How to install Perl with readline support? David Christensen <dpchrist@holgerdanske.com> - 2016-03-12 18:50 +0100
  Re: How to install Perl with readline support? David Christensen <dpchrist@holgerdanske.com> - 2016-03-12 18:40 +0100
    Re: How to install Perl with readline support? Kynn Jones <kynnjo@gmail.com> - 2016-03-12 19:50 +0100
      Re: How to install Perl with readline support? David Christensen <dpchrist@holgerdanske.com> - 2016-03-12 20:00 +0100

csiph-web