Disabling buffering on STDOUT seems to do the trick. Using strict and lexicals does hurt either.
#! perl -sw use strict; use Win32::Console ; $|++; # Disable buffering on STDOUT. my $password; my $cons = new Win32::Console(STD_INPUT_HANDLE) || die "Can't open new + console\n"; my $oldMode = $cons->Mode ; $cons->Mode(~(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT) & $oldMode ); while (1) { my $char = $cons->InputChar(1) ; last if ord $char == 13 ; print '*' ; $password .= $char ; } print "\nPassword was $password\n" ; $cons->Mode($oldMode) ; __END__ P:\test>junk **** Password was fred
In reply to Re: Win32::Console Modes not Working on XP
by BrowserUk
in thread Win32::Console Modes not Working on XP
by playingwithbots
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |