Wouter van Rooij wrote: > \ > > Hello, > > At the first place, sorry for my bad English. > My question is: > How can you, when you're writing a perl program, make a input > (<stdin>) hidden, so that when someone is typing an input in the > following program is hidden: > #!/usr/bin/perl > print "Your name:"; > $name = <STDIN> > I would like to get the input like this: ********
# stty plays with the terminal characteristics. # After disabling echo, anything the user types will no # longer show up on screen. # Disabling icanon disables buffering. If buffering is # enabled, you'll get stdin strings only after the user # presses enter. system "stty -echo -icanon"; # use sysread() and syswrite() for unbuffered read/write while (sysread STDIN, $a, 1) { if (ord($a) < 32) { last; } $b .= $a; syswrite STDOUT, "*", 1; # print asterisk } print "\nyou said: $b\n"; # Return terminal back to standard mode system "stty echo icanon";
signature.asc
Description: OpenPGP digital signature