Marto, thanks for the pointer... I suppose I should hang my head in shame that it was in the FAQ... but here's a little summary of what I found...
So the FAQ says that if you don't use Term::ReadKey you're stuck with ioctl (which all the documentation I've read thusfar seems to indicate I should avoid it like the plague... that it's nonportable, really cryptic, and difficult to use... made me dizzy...) nor does the FAQ really answer how in the world one uses ioctl() to do what i was asking (nor does the documentation on the command itself... it also mentions POSIX, but again, that's the whole POSIX system that it references, and my use case might've been in there somewhere... but sadly I lost the will to keep looking.
Luckily the Camel book mentions I can make a system call to stty -erase if I'm lucky enough to have that function supported by my OS (which I am! Yay! so I'll be using that...)
here's what worked for me...
print "Enter password: ";
system "stty -echo";
my $passwd = <STDIN>;
chomp $passwd;
system "stty echo";
print "Fool! I'm telling everyone your password is: $passwd\n";
Of course that requires those system commands to function as they do on your system... as they do on mine.
Anyhow thanks for the help, --Ray
ps if anyone has done an ioctl implementation, I'd love to see what it looks like... cuz the examples in that section were pretty gnarly.
| [reply] [d/l] |
The FAQ I linked to states in the first line:
"There's an example of this in crypt"
Which contains some code very similar to your solution.
| [reply] |
But stty is practically ioctl() in disguise??
| [reply] |
use v5.12;
use POSIX;
my $termios = POSIX::Termios->new(\*STDIN);
$termios->getattr;
my $lflag = $termios->getlflag;
$termios->setlflag($lflag & ~(&POSIX::ICANON) );
$termios->setattr;
my $pwd;
while (my $c = getc STDIN)
{
last if $c eq "\n";
print "\r \r";
$pwd .= $c;
}
$termios->setlflag($lflag);
$termios->setattr;
warn "GOT: $pwd\n";
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
| [reply] [d/l] |