Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Editing STDIN

by vladdrak (Monk)
on Dec 16, 2006 at 20:28 UTC ( #590228=note: print w/replies, xml ) Need Help??

in reply to Editing STDIN

You could use Term::InKey, like so:
use Term::InKey; print "password: "; my $password = ReadPassword("*"); print "\nYour password is '$password'\n";

Replies are listed 'Best First'.
Re^2: Editing STDIN
by rodion (Chaplain) on Dec 17, 2006 at 14:27 UTC
    Term::InKey is a good solution to the OP question, especially if he really does want to be able to modify characters before echoing, and he's just giving passwords as an example of this. One common use is uppercasing a sign-on or other field to indicate that it's case-insensitive.

    When doing this, remember to unbuffer STDOUT, as in:

    use warnings; use strict; use Term::InKey; use IO::Handle; STDOUT->autoflush(1); my $x=''; print "receiving chars\n"; while ($x ne 'x') { $x = ReadKey(); print uc($x); }
    Hope this helps.
Re^2: Editing STDIN
by Not_a_Number (Prior) on Dec 16, 2006 at 20:52 UTC

    I'm sorry, but I downvoted this node, for two reasons:

    1) It adds nothing to Corion's reply, posted more than four and a half hours earlier.

    2) Like the earlier response, it still doesn't address one of the OP's main problems, namely: 'One of our competition questions requests that we display input using asterisks'...

    Edit: Sincere apologies. Ignore the above! I misread use Term::InKey; as use Term::ReadKey;

    vladdrak+++, Not_a_Number--

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://590228]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-01-27 13:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found