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 indeed asks for a password and does not echo the answer but then it skips over the <STDIN> that follows it. I guess this is a bug in Term::ReadPassword::Win32 so I wonder if there is another module that works well on Windows?
http://www.perlmonks.org/?node_id=886306 reports the same issue and provides an alternate read-password implementation using Term::ReadKey. The underlying issue is this bug in Win32::Console, which can be worked around by reopening STDIN and/or STDOUT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With