Have you looked at Term::ReadKey's (alt./ppd) ReadMode?
ReadMode( noecho => STDIN );
my $password = <STDIN>;
ReadMode( restore => STDIN );
Things get a little trickier if you want asterisks to show up inplace of input, but nothing ReadKey, a loop, and print '*' can't handle...
--k.
| [reply] [d/l] |
You may want to take at a look at Term::ReadKey from CPAN.
From the docs:
The terminal mode function is controlled by the "ReadMode" function, which takes a single numeric argument, and an optional filehandle. This argument should be one of the following:
- 0: (Reset) Restore original settings.
- 1: (Cooked) Change to what is commonly the default mode, echo on, buffered, signals enabled, Xon/Xoff possibly enabled, and 8-bit mode possibly disabled.
- 2: (Cooked-Invisible) Same as 1, just with echo off. Nice for reading passwords.
- 3: (CBreak) Echo off, unbuffered, signals enabled, Xon/Xoff possibly enabled, and 8-bit mode possibly enabled.
- 4: (Raw) Echo off, unbuffered, signals disabled, Xon/Xoff disabled, and 8-bit mode possibly disabled.
- 5: (Really-Raw) Echo off, unbuffered, signals disabled, Xon/Xoff disabled, 8-bit mode enabled if parity permits, and CR to CR/LF translation turned off.
I didn't try it out, but it looks to be exactly what you need.
djw | [reply] |