简体   繁体   English

如何使用户输入(STDIN)在 PERL 中左右移动 - Unix 环境

[英]How to make User Input (STDIN) to move left and right in PERL - Unix Env

i'm a newbie in PERL.我是 PERL 的新手。 Whenever i tried to move left or right to delete characters in terminal it shows "^[[D^[[C^[[C^[[D".每当我尝试向左或向右移动以删除终端中的字符时,它都会显示“^[[D^[[C^[[C^[[D”。” Is there a way to make User Input (STDIN) to scroll left and right to delete the data in PERL?有没有办法让用户输入(STDIN)左右滚动以删除 PERL 中的数据?

i am looking for user to use keyboard arrows for example, to edit or correct what has just been typed without deleting the last entered characters with backspace.例如,我正在寻找用户使用键盘箭头来编辑或更正刚刚键入的内容,而不用退格删除最后输入的字符。

Example code: print "What is your Fav Food?; $food= STDIN;示例代码: print "What is your Fav Food?; $food= STDIN;

i want the readline to be flexible to delete the user entries.我希望 readline 能够灵活地删除用户条目。

STDIN is a LINE input operator. STDIN是一个 LINE 输入运算符。 You can change your input until you hit enter.您可以更改您的输入,直到您按下回车键。

You probably want one of these: https://www.cs.ait.ac.th/~on/O/oreilly/perl/prog3/ch02_11.htm您可能想要其中之一: https://www.cs.ait.ac.th/~on/O/oreilly/perl/prog3/ch02_11.htm

What you want is known as input line editing.您想要的称为输入行编辑。 For that, You can either user some terminal aware perl module for getting user Input ( https://metacpan.org/search?q=module%3ATerm%3A%3AReadline ).为此,您可以使用一些终端感知 perl 模块来获取用户输入( https://metacpan.org/search?q=module%3ATerm%3A%3AReadline )。 Or run your perl script under rlwrap ( https://linux.die.net/man/1/rlwrap ) command.或者在rlwrap ( https://linux.die.net/man/1/rlwrap ) 命令下运行 perl 脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM