Hello, I have an program that needs an userid and password. Then it tests an ftp connection. My question is I got the follow ing code from Mastering Perl5 by Eric Herrmann. What the code is doing is doubling the letters I am entering in the password. Two things can this code be fixed or does someone have an better way of doing it using Win32? The code to get password:
$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
So if the password is watch it prints out wwaattcchh. Any help would be welcomed. Hal.

In reply to Getting input for an password. by gindelhe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.