In addition to BrowserUK's suggestion of $|++; # Disable buffering on STDOUT. , the order of the mode change seems significant.

This works:

use Win32::Console ; $cons = new Win32::Console(STD_INPUT_HANDLE) || die "Can't open new co +nsole\n"; $|++; # Disable buffering on STDOUT. ConsoleMode_AND_WITH (~(ENABLE_ECHO_INPUT));# ConsoleMode_AND_WITH ( ~(ENABLE_LINE_INPUT));# while (1) { $char = $cons->InputChar(1) ; last if ord $char == 13 ; print '*' ; $password .= $char ; } print "\nPassword was $password\n" ; $cons->Mode($oldMode) ; sub ConsoleMode_AND_WITH(){ my $o = $cons->Mode(); $cons->Mode($o & shift); print "--Mode change from $o\[" . unpack(q(H2),chr($o)) . " ] to " . $cons->Mode() . "[". unpack(q(H2),chr($cons->Mode())) . "]\n"; }
Changing the order of ConsoleMode_AND_WITH calls produces the "Requires ENTER key" behaviour before anything shows up.

MS documentation says ENABLE_LINE_INPUT OFF should ignore the setting of ENABLE_ECHO_INPUT. But this is probably getting off-topic. Anyway, the code above does what you require, as does Browser's.


In reply to Re: Win32::Console Modes not Working on XP by NetWallah
in thread Win32::Console Modes not Working on XP by playingwithbots

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.