Okay, I'm seeing mixed info on whether or not Term::ReadKey works
properly with perl 5.8.0.  So, maybe I'll just throw out some code, and
see if others can get it to work.

I'm trying to wrap the ReadKey call in an infinite loop, but it breaks
as soon as I add the loop.  Take away the loop, or convert the ReadKey
to blocking, and it works just fine.  Here's the test code snippet I'm
using:

------------------------
use Term::ReadKey;

while (1) {
        ReadMode ('cbreak');
        if (defined ($char = ReadKey(-1)) ) {
                print "Char: $char\n";
        } else {
                print "None!\n";
        }
        ReadMode ('normal');
          sleep 1;
}
------------------------

Remove the while loop, or change the "-1" to "0", and it works properly.
As is, it never makes it into the "if defined" section of the if
statement.  I have one 5.6.1 box available, and it works fine there.
Can anyone with 5.8.0 test this out, and see if it works for them?

-----Original Message-----
From: Price, Jason (TLR Corp) 
Sent: Wednesday, December 08, 2004 1:36 PM
To: [EMAIL PROTECTED]
Subject: Term::ReadKey substitute for perl v5.8.0

In trying to use Term::ReadKey, I've come across information indicating
that Term::ReadKey does not work properly with Perl v5.8.0.  We are
running 5.8.0 on numerous systems, and upgrading them is not a trivial
thing, due to business reasons.  So, I need to find an alternative to
some ReadKey functionality.
 
I have a script that runs continuously, until explicitly ended by the
user (cntl-c), displaying updated results to the screen on a pre-defined
interval.  I want to allow the user to hit specific keys to define what
is being displayed on the screen.  So, I need the "ReadKey(-1)",
non-breaking functionality without using the Term::ReadKey module.  Any
ideas how I might accomplish this?
 
Thanks.
 
Jason

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to