Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Permanent prompt waiting for user command

by Lucas Rey (Sexton)
on Dec 03, 2022 at 07:45 UTC ( [id://11148524]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Permanent prompt waiting for user command
in thread Permanent prompt waiting for user command

Sure, I click the link :) Problem is that I still have issue on backspace and arrow using the example code:

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/; }

Replies are listed 'Best First'.
Re^5: Permanent prompt waiting for user command
by haukex (Archbishop) on Dec 03, 2022 at 07:58 UTC
    Problem is that I still have issue on backspace and arrow using the example code

    In that case the machine probably doesn't have a decent backend installed, such as Term::ReadLine::Gnu or Term::ReadLine::Perl, and you'll have to install it. This is sometimes easier using OS packages like libterm-readline-gnu-perl on Debian-based systems like Ubuntu.

    I'm not aware of any other core prompting modules that offer arrow key support (though I haven't checked ExtUtils::MakeMaker, which I mention here), and getting the proper modules onto the system will be much more worth the effort than any other wheel-reinventing.

    BTW, backspace not working seems kind of strange to me and you may want to check your terminal emulator settings.

    Edit: Fixed thinko.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found