Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the string in hidden way [duplicate]

Tags:

unix

perl

I am new to perl

I want to get password in invisible way

example: Enter the Password..?

**

it may space or any other symbol

while giving the input of the specified string

It should not visible to other even a input entering person

Is there any way to getting input in hidden way in perl

like image 896
Anitha Mani Avatar asked Jan 13 '23 01:01

Anitha Mani


2 Answers

Using System Function with stty command.

print "Enter The Password : ";  
system ("stty -echo");  
my $password = <STDIN>;  
system ("stty echo");

chomp $password;
like image 106
vara Avatar answered Jan 16 '23 00:01

vara


Recipe 15.10: "Reading Passwords"

Use the CPAN module Term::ReadKey, set the input mode to noecho , and then use ReadLine :

use Term::ReadKey;

ReadMode('noecho');
$password = ReadLine(0);
like image 38
Ignacio Vazquez-Abrams Avatar answered Jan 16 '23 02:01

Ignacio Vazquez-Abrams