Verified on Active State perl, v5.10.1 built for MSWin32-x86-multi-thread.

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; }

In reply to Re: Term::ReadKey(0) and Windows by Marshall
in thread Term::ReadKey(0) and Windows by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.