For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > May 2005 > How to input one char at a time from stdin









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to input one char at a time from stdin
aleppos

2005-05-08, 12:10 pm

I'd like to get a character from stdin, perform some action, get another
character, etc. If I just use read(stdin, 1).., it waits until I finish typing
a whole line before I can get the first character. How do I deal with this?


Aleppos
displeaser

2005-05-23, 10:10 am

Hi,

you can use the Term::Inkey module which can be found here:
http://search.cpan.org/~razinf/Term...4/Term/InKey.pm


#An example using the Inkey module
use strict;
use warnings;
use Term::InKey;

my $x="";
while($x ne "q"){
$x = &ReadKey;
print "You pressed $x\n";
}
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com