Hello All, 

I am having trouble figuring this out. Maybe one of you can help. I am trying 
to use the Win32::Console module in a function call, but when the function 
exits the Console object gets deleted and my application looses its handle. 
Does anyone know how to use this without this side effect? Some example code 
below. 

Thanks, 
dhorn

# Start Code

use Win32::Console;
use strict;

my $pass = &getUserPass;
print "Pass: $pass\n";

print "Enter something: ";
my $text = <STDIN>; # <- Does not grab standard input. 
print "TEXT: $text\n";



sub getUserPass {
  my $stdin = new Win32::Console(STD_INPUT_HANDLE); 
  my $pwd = ""; 
  $stdin->Mode(ENABLE_PROCESSED_INPUT); 
  local $| = 1;  
  print "Enter Password: "; 
  while (my $input = $stdin->InputChar(1)) { 
    if("\r" eq $input ) { 
      last; 
    } elsif ("\b" eq $input ) { 
      if( "" ne chop( $pwd )) { 
        print "\b \b"; 
      } 
      next; 
    } 
    $pwd .=$input; 
    print "*"; 
  } 

  print "\r" . " " x (40) . "\r";
  return $pwd;
} 

# End code


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to