in reply to Re: masking password entry
in thread masking password entry

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.