Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Revising Input Method

by hakonhagland (Scribe)
on Jul 28, 2016 at 20:47 UTC ( [id://1168760]=note: print w/replies, xml ) Need Help??


in reply to Revising Input Method

According to the documentation the package is just a front end to some other packages. It's a stub to set up a common interface to the various ReadLine implementations found on CPAN (under the Term::ReadLine::* namespace). If you haven't installed any additional packages like Term::Readline::Gnu or Term::ReadLine::EditLine, it will default to an internal default package called Term::ReadLine::Stub, this default package is very simple, and does not understand things like arrow keys. You can use $term->ReadLine to determine which package it is actually using, see below example.

I tried to install Term::ReadLine::Gnu on my Ubuntu laptop:

$ sudo apt-get install libncurses5-dev libreadline6-dev $ cpanm Term::ReadLine::Gnu
Then I tried
use feature qw(say); use strict; use warnings; use Term::ReadLine; my $term = Term::ReadLine->new('Test', \*STDIN, \*STDOUT); say "I am using the following ReadLine package: " . $term->ReadLine; $term->ornaments( 0 ); $term->addhistory("sample text added to history"); while (1) { my $line = $term->readline( 'Enter input: ' ); say "You entered: '$line'"; }

Now the up and down arrow keys are recoginzed, and used to recall the history lines. There are also some useful Emacs keybindings available, see Command Line Editing in the Gnu Bash manual for more information.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1168760]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-29 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found