gindelhe has asked for the wisdom of the Perl Monks concerning the following question:
So if the password is watch it prints out wwaattcchh. Any help would be welcomed. Hal.$console=Win32::Console->new(STD_INPUT_HANDLE); print<<"eof"; Enter Your novell password Crtl + U to erase line, Crtl + H or backspace to delete an character Carriage return (Enter key) to end entry eof GETPASSWORD: while (($char = ($console->Input())[5]) != $CARRIAGE_RETURN ) { SWITCH:{ #test for crtl h if ($char == 8){ print "\b \b"; chop $password; last SWITCH; } # test for crtl u if ($char == 21){ $currentInputSize = length($password); print "\b \b" x $currentInputSize; last SWITCH; } #Carriage Return if ($char == 13){ if (length ($password) == 0){ print "PASSWORD REQUIRED \n"; exit; } # stop entry, exit loop last GETPASSWORD; } #Strip out extra stuff if ($char >= 0x21 && $char <= 0x7E){ #convert number to ASCII int $password .= chr $char; print "*"; last SWITCH; } # must call Console::Input twice $char = ($console->Input())[5]; } #end get password
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting input for an password.
by moodster (Hermit) on May 22, 2002 at 11:13 UTC |