Marc Olivier wrote:

> Hello.
> I'm trying to get keyboard input to work in a Perl script on Windows
> platform. The snippet that's giving me trouble is
> =================================================
> # turn off echoing but don't interfere with STDIN
> # open (TTY, "/dev/tty") or die "Cannot Open terminal\n";
> ## --------------------------------------------------------
> ## "Cannot Open Terminal" comes up when this code runs under Windows
> ## ---------------------------------------------------------
>  system ("stty -echo < /dev/tty");
>  print STDERR "Enter Password: ";
>  chomp ($password=<TTY>);
>  system ("stty echo < /dev/tty");
>  close (TTY);
>  print STDERR "\n";
> ====================================================
> 
> This doesn't work on Windows, only Linux. Does someone have a better way to
> address the keyboard in Perl?



use Term::ReadKey;

ReadMode('noecho');
$password = ReadLine(0);


See Perl Cookbook page 530.

Paul R