Hello,
I have a problem! As part of a larger script I am printing out data sent through a socket connection from another pc into the command prompt. While the text is being displayed on screen I want the user to be able to exit this part of the program, ideally with a single key press (say 'x').
I have been trying to get it working with Term::ReadKey but due to the way I am reading in the data from the socket I am never reaching the condition in the while. Here is the code snipet:
----------------------------------------------------------
ReadMode 5; # Turns off controls keys
while(1)
{
while (not defined ($qKey = ReadKey(-1)))
{
while ($client = $peerSock->accept())
{
print "\n\n> Client connected\n\n";
while(defined ($buf = <$client>))
{
print "$buf";
}
}
}
($qKey eq 'x') and last; # Condition which is never reached
}
ReadMode 0; # Reset read mode before exiting
----------------------------------------------------------
Am I on the right line or should I forget about Term::ReadKey and use something else? Any help would be much appreciated. Thanks