Re: hiding input
by arturo (Vicar) on Nov 17, 2000 at 02:09 UTC
|
use Term::Readkey;
ReadMode('noecho');
$pwd = ReadLine(0);
(Lifted from the Perl Cookbook, p. 529)
Philosophy can be made out of anything. Or less -- Jerry A. Fodor | [reply] [Watch: Dir/Any] [d/l] |
|
tried this, and got the error:
Can't locate Term/Readkey.pm in @INC
(@INC contains: /opt/perl5/lib/PA-RISC1.1/5.00404
/opt/perl5/lib /opt/perl5/lib/site_perl/PA-RISC1.1
/opt/perl5/lib/site_perl .) at ./prog line 14.
BEGIN failed--compilation aborted at ./prog line 14.
| [reply] [Watch: Dir/Any] [d/l] |
|
You don't have the module installed, and you'll have to install the module, I'm afraid. If you have root access (or you can get the admin to do this for you) I'd advise using the CPAN module.
perl -MCPAN -e 'install Term::Readkey'
from the command line. Read perlmodinstall for more info on installing modules.
Philosophy can be made out of anything. Or less -- Jerry A. Fodor | [reply] [Watch: Dir/Any] [d/l] |
|
That's because you probably don't have it installed. Grab it from CPAN.
IDENTIFICATION DIVISION.
PROGRAM-ID. redmist.
AUTHOR. God (Larry Wall/Alan Cox hybrid).
CONTACT. redmist@users.sourceforge.net
| [reply] [Watch: Dir/Any] |
|
You may yet have it installed. It's actually supposed to be use Term::ReadKey. Note the capital K in ReadKey.
| [reply] [Watch: Dir/Any] |
(redmist) Re: hiding input
by redmist (Deacon) on Nov 17, 2000 at 02:11 UTC
|
use Term::ReadKey;
print "Enter your passwd: ";
ReadMode 'noecho';
$passwd = ReadLine 0;
chomp $passwd;
ReadMode 'normal';
From the Perl Cookbook, pg, 530.
{EDIT: Dammit! arturo beat me by 2 minutes!}
IDENTIFICATION DIVISION.
PROGRAM-ID. redmist.
AUTHOR. God (Larry Wall/Alan Cox hybrid).
CONTACT. redmist@users.sourceforge.net
| [reply] [Watch: Dir/Any] [d/l] |
Re: hiding input
by cianoz (Friar) on Nov 17, 2000 at 04:28 UTC
|
as many have told you, you should install and use Term::Readkey, however there is another (dirty) way
(at least on unix):
system('stty -echo');
print "insert key:";
$key = <STDIN>;
system('stty echo');
| [reply] [Watch: Dir/Any] [d/l] |
|
tried this, and it works great...I am gonna have to use this method.
I played around with installing the module on our test box,
just to learn a little on how it all works n stuff, but
the powers that be wont let me install "extra stuff" on all
of our servers. so this is a great alternative...thank you ;)
| [reply] [Watch: Dir/Any] |
Re: hiding input
by Anonymous Monk on Nov 18, 2000 at 11:09 UTC
|
If you are working on UNIX platform, this is an easier task.
Use optionally echoing of input facility of UNIX.
Try this :
printf("Enter word :");
chomp($visible_word = <STDIN>>); #### you can see what you are typin
+g ...
printf("\n");
system("stty -echo");
chomp($passwd = <STDIN>); #### this won't be visible on screen ...
printf("\n");
system("stty echo");
| [reply] [Watch: Dir/Any] [d/l] |