Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Aug 2005 15:58:13 +0800
From:      "Daniel Marsh" <daniel@stiw.org>
To:        "Michael Beattie" <mtbeedee@gmail.com>, "Wouter van Rooij" <aentgood@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: perl <stdin>
Message-ID:  <op.suynm1jejjurwa@spock.enterprise.prvt>
In-Reply-To: <d4b4435a0508031838516cd4d9@mail.gmail.com>
References:  <7603e5d805080317593a046eec@mail.gmail.com> <7603e5d8050803181766be524b@mail.gmail.com> <d4b4435a0508031838516cd4d9@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 04 Aug 2005 09:38:15 +0800, Michael Beattie <mtbeedee@gmail.com>  
wrote:

> On 8/3/05, Wouter van Rooij <aentgood@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.suynm1jejjurwa>