Don't want to see user input

I want to prompt the user for input
and assign the user input to a scalar
variable but I don't want the user input
to be displayed as it is being typed.
How do I accomplish this ? Thanks.
LVL 1
zmanzAsked:
Who is Participating?
 
ddaConnect With a Mentor Commented:
If you are not in unix, you can yse Term::ReadKey module:

#!perl -w

use strict;

use Term::ReadKey;

print "Enter password: ";
my $pass = hidden_read();
print "\nYou entered: \"$pass\"\n";

exit;

# ================
sub hidden_read {
    my $str;
    ReadMode 2;
    $str = ReadLine 0;
    ReadMode 0;
    chomp $str;
    return $str;
}
0
 
maneshrCommented:
#!/usr/local/bin/perl

system "stty -echo";
print "Enter :";
chomp($in=<STDIN>);
system "stty echo";

This solution is provided in the Programming PERL book
0
All Courses

From novice to tech pro — start learning today.