D
Dr.Ruud
Ilya Zakharevich schreef:
perl was run from a Win2000 CMD.EXE console. I am not aware of anything
special on this system.
I am retrying the USE_GETC options ... yes, confirmed what was written
there. The source that I used:
#!/usr/bin/perl
use strict;
use warnings;
use constant # Unix # Win32 #
{ USE_CONIN => 0 # 0 # 1 #
, USE_GETC => 0 # - # - #
, SET_BINMODE => 0 # 0 # 1 #
, SET_READMODE => 4 # 5 # 4/5 #
};
use Term::ReadKey; # if defined SET_READMODE;
sub my_getc {
my $in = @_ ? shift : <STDIN>;
return getc $in if USE_GETC;
my $buf;
return -1 if read($in, $buf, 1) < 1;
return substr($buf, 0, 1);
}
my $fname = USE_CONIN ? 'CONIN$' : '-';
open my $con, "+< $fname" or die "Can't open '$fname': $!";
if (defined SET_READMODE) {
ReadMode SET_READMODE, $con;
}
if (SET_BINMODE) {
binmode $con or die "Can't binmode '$fname': $!";
}
while ( defined($_ = my_getc($con)) ) {
my $ord = ord;
print "Esc " if $ord == 27;
print "|$_| " if $ord >= 32;
print "<", $ord, ">\n";
last if $ord == 3;
}
if (defined SET_READMODE) {
ReadMode 0, $con;
}
close $con;
__END__
This produces a burst of three <13>s, once the third Enter is hit. So
the <13>s get delayed, but none gets eaten.
With USE_GETC set to 1, I need to hit Enter four times, after which a
burst of three <13>s is displayed. So one gets eaten.
Dr.Ruud:
On a "correctly set up" read() from "DOS console", pressing `Left'
should generate two characters, 0 and 75; likewise for other special
keys.
perl was run from a Win2000 CMD.EXE console. I am not aware of anything
special on this system.
Then I have no idea what it is you write about in the part quoted with
"> >>"... And the fault of PerlIO is not yet proven...
I am retrying the USE_GETC options ... yes, confirmed what was written
there. The source that I used:
#!/usr/bin/perl
use strict;
use warnings;
use constant # Unix # Win32 #
{ USE_CONIN => 0 # 0 # 1 #
, USE_GETC => 0 # - # - #
, SET_BINMODE => 0 # 0 # 1 #
, SET_READMODE => 4 # 5 # 4/5 #
};
use Term::ReadKey; # if defined SET_READMODE;
sub my_getc {
my $in = @_ ? shift : <STDIN>;
return getc $in if USE_GETC;
my $buf;
return -1 if read($in, $buf, 1) < 1;
return substr($buf, 0, 1);
}
my $fname = USE_CONIN ? 'CONIN$' : '-';
open my $con, "+< $fname" or die "Can't open '$fname': $!";
if (defined SET_READMODE) {
ReadMode SET_READMODE, $con;
}
if (SET_BINMODE) {
binmode $con or die "Can't binmode '$fname': $!";
}
while ( defined($_ = my_getc($con)) ) {
my $ord = ord;
print "Esc " if $ord == 27;
print "|$_| " if $ord >= 32;
print "<", $ord, ">\n";
last if $ord == 3;
}
if (defined SET_READMODE) {
ReadMode 0, $con;
}
close $con;
__END__
This produces a burst of three <13>s, once the third Enter is hit. So
the <13>s get delayed, but none gets eaten.
With USE_GETC set to 1, I need to hit Enter four times, after which a
burst of three <13>s is displayed. So one gets eaten.