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