[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Password Dialog



Chris Nandor skrev/wrote:
>Yes.  This should work, I think:
>
>#!perl -w
>print "Enter your password: ";
>`stty raw`;
>chomp($pass = <STDIN>);
>print "Your password is $pass\n";
>`stty sane`;
>__END__
>
>But in actuality, it does not work for me.  Hrm.  I get:
>
>Enter your password: # Use of uninitialized value.
>File 'Untitled #4'; Line 4
># Use of uninitialized value.
>File 'Untitled #4'; Line 5
>Your password is

I use ths code which is from the dark ages (i.e. I don't remember ;-)
#####
print "your password:\n";

`stty raw`;

$i = 0;

do {
  do {
   $_ = getc;
   if (/\010/){
	--$i if $i >= 0; # pop @min if $#min >= 0;
	undef $min[$i] if $i >= 0;
   } else {
	$min[$i] = $_;
   }

  } until (defined $min[$i]);
  ++$i;
} until ($min[$i - 1] eq "\n");

`stty sane`;
pop @min;
$passwd = join("",@min);
#####
Christian
<http://www.solvare.se/individer/christian/>
______________________________________________________
Solvare     -    let's solve it!
<http://www.solvare.se>

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch