in reply to Password Entry using Core modules only?

It's in the FAQ, How do I ask the user for a password?.

  • Comment on Re: Password Entry using Core modules only?

Replies are listed 'Best First'.
Re^2: Password Entry using Core modules only?
by raybies (Chaplain) on Mar 12, 2013 at 19:56 UTC

    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.

      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.

      But stty is practically ioctl() in disguise??