在Perl5中,Term::Readline不接受箭头键
我正在尝试诊断和修复Linux上Perl应用程序在Perl5中,Term::Readline不接受箭头键,perl,terminal,Perl,Terminal,我正在尝试诊断和修复Linux上Perl应用程序youtube viewer的一个bug。我不懂任何Perl,这可能会变成一个Linux问题,而不是Perl问题 因此,在Perl 5中使用Term::ReadLine时,ReadLine()似乎不接受终端中的箭头键–我尝试了rxvt unicode和xterm。这里有一个最小的例子 #!/usr/bin/perl require Term::ReadLine; $term = Term::ReadLine->new(""); $term-
youtube viewer
的一个bug。我不懂任何Perl,这可能会变成一个Linux问题,而不是Perl问题
因此,在Perl 5中使用Term::ReadLine
时,ReadLine()
似乎不接受终端中的箭头键–我尝试了rxvt unicode
和xterm
。这里有一个最小的例子
#!/usr/bin/perl
require Term::ReadLine;
$term = Term::ReadLine->new("");
$term->readline("");
运行此操作并按箭头键←代码>↓代码>→代码>↑代码>打印
^[[D^[[B^[[C^[[A
而不是移动光标
这是否可能是一个Term::ReadLine
错误,或者如何修复?接下来我可以做什么来找出这里的错误?您可能还需要安装Term::ReadLine::Perl
或Term::ReadLine::Gnu
。尝试以下方法:
sudo cpan Term::ReadLine::Gnu
sudo cpanm Term::ReadLine::Perl
sudo apt install libterm-readline-gnu-perl # if ubuntu or
sudo apt install libterm-readline-perl-perl #
sudo yum install perl-Term-ReadLine-Gnu # if centos, rhel, fedora
它对我有用。您的$TERM
环境变量设置正确吗?@KeithThompson是的,它设置为rxvt-unicode-256color
,我认为这对于rxvt-unicode
应该是正确的。因此,这可能确实是一个Linux问题,对吗?“这个包只是其他一些包的前端。它是一个存根,用于为CPAN(在C命名空间下)上的各种ReadLine实现设置一个公共接口。”“您可能使用了不同的后端。您是否安装了Term::ReadLine::Gnu?@ikegami就是这样。如果你对我的回答做出这样的评论,我会接受的。非常感谢。