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

awesome!!!! Thanks everyone for all your help!!!! Both suggestions worked equally well!

Replies are listed 'Best First'.
Re: masking password entry
by samarzone (Pilgrim) on May 04, 2010 at 18:24 UTC

    The line

    while (my $KeyPressed = $StdIn->InputChar(1))

    should be changed to

    my $KeyPressed; while (defined ($KeyPressed = $StdIn->InputChar(1)))
      my $KeyPressed; while (defined ($KeyPressed = $StdIn->InputChar(1)))

      It's possible to maintain the scoping of  $KeyPressed used in the OP code:
          while (defined(my $KeyPressed = $StdIn->InputChar(1))) {
              ...
              }

      The reason the original code 'fails' is that a '0' character entered by the user evaluates as false, and the  while loop ceases iteration in consequence.

Re: masking password entry
by VinsWorldcom (Prior) on May 04, 2010 at 18:11 UTC

    On Windows XP with ActiveState, I've used:

    use Term::ReadKey; print "Password: "; my $password = GetPass(); print "$password\n"; sub GetPass { # No echo password ReadMode 2; chomp(my $opt = <STDIN>); ReadMode 0; print "\n"; return $opt }