in reply to Term::ReadKey(0) and Windows
I did notice one additional quirk: the sequence of alpha char, Enter, alpha char, Enter, alpha char, etc -> the enter isn't displayed until the following alpha character is pressed (and the 13 comes before that char). That sequence can evidently repeat forever. After a few tries like that Enter,Enter,Enter,Enter is required to get a single Enter to appear (first 3 vanished) as reported.
Sorry I don't know why this happens, but this alternating behaviour might be an additional clue.
Update: I think the answer elsewhere explained is a bug in Term::ReadKey and updating that module is clearly a great solution. I was hacking around with this prior to seeing that solution and found a way to make the desired output happen even with ActivePerl 5.10. I was surprised that ReadMode made a difference even when binmode was selected for stdin. Anyway there aren't any missing 013's in this code. Other readmodes will cause both the carriage return and line feed characters to appear and CTRL-C is a "3" instead of what it normally does and CTRL-break is required. Anyway...for whatever entertainment value it may have ...
#!/usr/bin/perl -w use strict; use Term::ReadKey; ReadMode (3); #try mode 4 also! while (1) { binmode('stdin'); my $buf; read('stdin', $buf, 1, 0); print ord $buf; }
|
|---|