PERL:



              

PERL: - . 505


pnntf Kill is character %d, %s\n , $, uncontrol(chr($kill)),

$term->setcc(VERASE, ord(#')); $tern->setcc(VKILL, ord('@>')); $term->setattr(1, TCSANOW);

print('erase is #, kill is @, type something: ' ),

$line = <STDIN>;

print "You typed: $line";

$term->setcc(VERASE, $erase); $term->setcc(VKILL, Skill); $terrn->setattr(1, TCSANOW);

sub uncontrol {

local $_ = shift,

s/([\200-\377])/spnntf( M-%c",ord($1) & 0177)/eg;

s/([\0-\37\177])/sprintf('"%c",ord($1) " O100)/eg;

return $_; }

, HotKey, read key Perl. ­ Term::ReadKey, ­ termios :

# HotKey pm
package HotKey;


534 15

@ISA = qw(Exporter),

@EXP0RT = qw(cbreak cooked readkey);

use strict;

use POSIX qw(:termios_h);

my ($term, $oterm, $echo, $noecho, $fd_stdin);

$fd_stdin = fileno(STDIN); $term = POSIX:.Termios->new(), $term->getattr($fd_stdin); Soterrn = $term->getlflag(),

$echo = ECHO | ECHOK | ICANON, $noecho = $oterm & ~$echo;

sub cbreak {

$term->setlflag($noecho); # - $term->setcc(VTIME, 1), $term->setattr($fd_stdin, TCSANOW);

sub cooked {

$term->setlflag($oterm); $term->setcc(VTIME, 0), $term->setattr($fd_stdin, TCSANOW);

sub readkey { my $key = ''; cbreak(),

sysread(STDIN, $key, 1); cooked(); return $key;

END < cookedO }

>

POSIX; 15.6; 15.9.

15.9.

, , .


15.10. 535

Term::ReadKey CPAN , -1:

use Term':ReadKey, ReadMode ('cbreak');

if (defined ($char = ReadKey(-D) ) {