How to request a password on a Windows console in a Perl script?

I tried the following code

use strict; use warnings; use Term::ReadPassword::Win32 qw(read_password); my $pw = read_password('pw: '); print "pw $pw\n"; my $x = <STDIN>; print "x: $x\n"; 

It really asks for the password and does not respond to the answer, and then skips the <STDIN> that follows it. I assume this is an error in Term :: ReadPassword :: Win32, so I am wondering if there is another module that works well on Windows?

+6
source share
1 answer

http://www.perlmonks.org/?node_id=886306 reports the same problem and provides an alternative read-password implementation using Term :: ReadKey. The main problem is this error in Win32 :: Console , which can be circumvented by reopening STDIN and / or STDOUT.

+3
source

Source: https://habr.com/ru/post/906308/


All Articles