Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Permanent prompt waiting for user command

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

Lucas Rey has asked for the wisdom of the Perl Monks concerning the following question:

Dear monkers, I need a permanent prompt to listen for user commands. The code I'm currently using is the following:
sub promptUser { local($promptString,$defaultValue) = @_; print $promptString; $| = 1; $_ = <STDIN>; chomp; return $_; } while (1) { $command = &promptUser("ABC> "); }

The above code works perfect, and store what user write into $command variable. The problem is that in this prompt, Backspace and arrows doesn't work. I got something like: ^H^[[A^[[B . So for delete chars I have to use canc, but I cannot use arrows to move into what I wrote or UP and DOWN to surf into history like bash already do. Is there a way to use backspace and/or arrows without external module? (I'm in a server offline)
Thank you Lucas

Replies are listed 'Best First'.
Re: Permanent prompt waiting for user command
by haukex (Archbishop) on Dec 03, 2022 at 07:30 UTC
      Hi, no problem with "use Term::ReadLine;", thank you. Do you have any example code?
        Do you have any example code?

        I thought the Synopsis in the documentation would be enough - you did click the link, right? If you are having trouble with the module, please post the code you're having problems with. See SSCCE and How do I post a question effectively?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11148520]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found