k1ng0fn3rd
Programmer
I'm trying to find a function in perl that takes only the first character typed in STDIN, returns it, then just moves on, like the C++ getch().
Is there any way to do this?
Is there any way to do this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
read stdin, $_, 1;
It's all there ...CPAN said:ReadKey MODE [, Filehandle]
Takes an integer argument, which can currently be one of the following values:
0 Perform a normal read using getc
-1 Perform a non-blocked read
>0 Perform a timed read
GETC
Returns the next character from the input file attached to FILEHANDLE, or the undefined value at end of file, or if there was an error (in the latter case $! is set). If FILEHANDLE is omitted, reads from STDIN. This is not particularly efficient. However, it cannot be used by itself to fetch single characters without waiting for the user to hit enter.
perldoc.perl.org