Title: accepting passwords from console apps

I am currently using Term::ReadKey to read in the characters.

With the ReadMode(noecho) I can get a hidden password, however there is no way for my not tech savy client to tell if what they typed actually entered.

My code is an attempt to use ReadKey, and display an asterisk for each keystroke that is not the enter key.  This snippet will display an asterisk, however you must press the enter key twice in order to get it to return.

Im currently using PERL v5.8.2.  Has anyone been able to

Thank you,

-- Aaron

######################################################

print "\n",&getpwd();

sub getpwd

{

        my @password;

        my $char = "";

        print "Please Enter your Password:";

        use Term::ReadKey;

        ReadMode('cbreak');

        #while ($char ne '\n')

        #for (my $i=0;$i<5;$i++)

        until (0)

        {

                $char = ReadKey(0);

                if (ord($char) eq 13) {return @password;}

        ## I have tried /n and /r, and neither of these will prompt a valid response from the IF statement.

                print "*";

                push(@password,$char);

        }

}

Reply via email to