Perl 是否有类似于”的东西;“键盘”;不使用;诅咒;?

Perl 是否有类似于”的东西;“键盘”;不使用;诅咒;?,perl,console,terminal,Perl,Console,Terminal,从外部看是否有类似于键盘(1)的功能? 我想写这样的东西,但不使用诅咒,也不自己处理转义序列 #!/usr/bin/env perl use warnings; use 5.012; use Curses; initscr(); raw(); printw( qq{Press "Delete"} ); noecho(); keypad(1); my $c = getch(); endwin(); if ( $c =~ /\A330\z/ ) { say "OK"; } else {

从外部看是否有类似于键盘(1)的功能? 我想写这样的东西,但不使用
诅咒
,也不自己处理转义序列

#!/usr/bin/env perl
use warnings;
use 5.012;
use Curses;

initscr();
raw();
printw( qq{Press "Delete"} );
noecho();
keypad(1); 
my $c = getch();
endwin();

if ( $c =~ /\A330\z/ ) {
    say "OK";
} else {
    say qq{You didn't press "Delete"};
}
当我使用
Term::ReadKey
时,它的行为不同:

#!/usr/bin/env perl
use warnings;
use 5.012;
use Term::ReadKey;

ReadMode('raw');

print qq{Press "Delete" };
while ( 1 ) {
    my $c = ReadKey( 0 );
    last if $c eq 'q';
    say "<$c>";
}

ReadMode('normal');
#/usr/bin/env perl
使用警告;
使用5.012;
使用Term::ReadKey;
读取模式(“原始”);
打印qq{按“删除”};
而(1){
my$c=ReadKey(0);
最后一个if$c eq‘q’;
说“”;
}
读取模式(“正常”);
按“删除”后的输出:

按“删除”<

你想要避免的诅咒是什么


你会发现这很有用。它是一个指向库的Perl接口,用于处理键盘控制字符、多字节转义序列和UTF-8字符。

您希望避免的诅咒是什么

你会发现这很有用。它是库的Perl接口,用于处理键盘控制字符、多字节转义序列和UTF-8字符。

如前面所述,可能有助于:

use warnings;
use 5.012;
use Term::TermKey;

my $tk = Term::TermKey->new( \*STDIN );

print qq{Press "Delete" };
while( 1 ) {
   $tk->waitkey( my $key );
   say "<", $tk->format_key( $key, 0 ), ">";
}
使用警告;
使用5.012;
使用Term::TermKey;
my$tk=Term::TermKey->new(\*STDIN);
打印qq{按“删除”};
而(1){
$tk->waitkey(我的$key);
说“”;
}
给予

按“删除”
如所述,可能有助于:

use warnings;
use 5.012;
use Term::TermKey;

my $tk = Term::TermKey->new( \*STDIN );

print qq{Press "Delete" };
while( 1 ) {
   $tk->waitkey( my $key );
   say "<", $tk->format_key( $key, 0 ), ">";
}
使用警告;
使用5.012;
使用Term::TermKey;
my$tk=Term::TermKey->new(\*STDIN);
打印qq{按“删除”};
而(1){
$tk->waitkey(我的$key);
说“”;
}
给予

按“删除”

不行吗?行了,但工作量更大。不这样做?它确实这样做了,但这是更多的工作。当我使用
诅咒
时,我看不到我在使用诅咒之前写到控制台的部分,所以我必须用诅咒来写所有内容。当我使用
诅咒
时,我看不到我在使用诅咒之前写到控制台的部分,所以我必须用诅咒来写所有内容。
Press "Delete" <Delete>