For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > Checking for keyboard input without halting process









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 Checking for keyboard input without halting process
Zikester

2004-04-29, 10:09 am

I've racked my brain for an answer to this one. Probably real simple.....

I'd like to run a process reatedly until entering a character on the
keyboard (other than ^C). When the character is entered the process would
complete some final tasks and exit the program.

do {
# a process
$Keyboard_Input = (check_for_input);
} until ($Keyboard_Input);
# some final tasks


I've tried to use the standard input file <STDIN> without success.
I've tried
$Keyboard_Input = <STDIN>; which just halts the script until the Enter key
is pressed.
$Keyboard_Input = eof (STDIN); which halts until the Enter key is pressed
and then returns a null character thereafter
$Keyboard_Input = tell (STDIN); which returns a '0' character even if the
Enter key is pressed,

OK, so what am I missing here? Do I need to use something other than the
Standard Input File structure?


John W. Krahn

2004-04-29, 10:09 am

Zikester wrote:
>
> I've racked my brain for an answer to this one. Probably real simple.....
>
> I'd like to run a process reatedly until entering a character on the
> keyboard (other than ^C). When the character is entered the process would
> complete some final tasks and exit the program.


Perhaps this will help:

perldoc -q keyboard


John
--
use Perl;
program
fulfillment
Sponsored Links







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

Copyright 2008 codecomments.com