Dirty Luigi has asked for the wisdom of the Perl Monks concerning the following question:

I wrote a program with a text editor in it. It is a password screen. I was wondering how to make the text that the user typed in the "STAR" format.

Replies are listed 'Best First'.
Re: Password Text
by tachyon (Chancellor) on May 16, 2004 at 23:29 UTC

    By STAR format I assume you mean when the user types in the password you want ***** to appear not the actual password. With CGI/HTML you would use the <input type=password name=pass> type tag. But you don't say what you are using. Besides HTML it could be Shell (dos/unix), Curses, Tk, Wx or .....? If you either post code of specify what you are using then you may just get a useful answer.

    Your question is pretty obtuse BTW. A better question might be I have a program using (Curses|CGI|.*) I need to prompt the user for a password. At the moment the password appears in plain text on the screen. I want it to appear as ****. How can I do this?

    perlfaq8 gives this example (no stars but no plaintext either)

    use Term::ReadKey; ReadMode('noecho'); $password = ReadLine(0);

    Of course CPAN provides a convenience version of this basic algorithm Term::ReadPassword that handles backspaces etc.

    cheers

    tachyon

Re: Password Text
by tachyon (Chancellor) on May 16, 2004 at 23:48 UTC

    It appears from a previous node that you are using Tk. So see this: how to accept password using Tk which gives a few solutions (with ***** format :-). Please have a look at Super Search which is where this link came from.

    cheers

    tachyon