perl <stdin>
Daniel Marsh
daniel at stiw.org
Thu Aug 4 07:58:18 GMT 2005
On Thu, 04 Aug 2005 09:38:15 +0800, Michael Beattie <mtbeedee at gmail.com>
wrote:
> On 8/3/05, Wouter van Rooij <aentgood at gmail.com> wrote:
>> \
>>
>> Hello,
>>
>> At the first place, sorry for my bad English.
>> My question is:
>> How can you, when you're writing a perl program, make a input
>> (<stdin>) hidden, so that when someone is typing an input in the
>> following program is hidden:
>> #!/usr/bin/perl
>> print "Your name:";
>> $name = <STDIN>
>> I would like to get the input like this: ********
>>
The PERL Cookbook seems to have the answer.
Problem
You want to read input from the keyboard without the keystrokes being
echoed on the screen. For instance, you want to read passwords as passwd
does, i.e. without displaying the user's password.
Solution
Use the CPAN module Term::ReadKey, set the input mode to noecho, and then
use ReadLine:
use Term::ReadKey;
ReadMode('noecho');
$password = ReadLine(0);
More information about the freebsd-questions
mailing list