>> Is Term::ReadKey the solution to this? I've read that it *could* be, >> however in any implimentation I've tried to use it doesn't quite work. Any >> help to get this thing working would be greatly appreciated. >I don't see what you need it for. Are you trying to avoid blocking on >the console read or what ? Yes, a standard <STDIN> will pause the loop untill input is in. I'm looking for a way to accept keyboard input without the pause. Your suggestion works exactly the same way my second meathod does. It doesn't refresh, untill you enter a command. Then it refreshes one line, and waits for another command. D- -----Original Message----- From: $Bill Luebkert [mailto:[EMAIL PROTECTED]] Sent: Saturday, August 18, 2001 1:26 PM To: Daniel L Quigley-Skillin Cc: [EMAIL PROTECTED] Subject: Re: ReadKey? Daniel L Quigley-Skillin wrote: > > Appologies if this is a duplicate. I didn't recieve acknowledgement of my > first send, nor have I recieved that message from the list. You appeared to have replied to another thread instead of starting a new one. > A couple days ago I asked for some help with a refresh loop which monitors a > telnet pipe, and maintaining the ability to input commands without a pause. > > Is Term::ReadKey the solution to this? I've read that it *could* be, > however in any implimentation I've tried to use it doesn't quite work. Any > help to get this thing working would be greatly appreciated. I don't see what you need it for. Are you trying to avoid blocking on the console read or what ? > Here are the two primary meathods I've tried and thier setbacks. BTW in > each example I have tried modes 0-5 for ReadMode. > > First attempt does a great job monitoring the pipe, it cleanly monitors the > pipe and refreshes the screen. Two issues, the first, I run OUT OF MEMORY > and of course the LOGIC IS BAD >=0 will always yield a TRUE result, hence > never accepting input. > > use Term::ReadKey; > > <----SNIP!----> > > sub refresh > { > $hosttxt=$host->getline; > if (length($hosttxt) >= 0) > { > print "$hosttxt"; > $hosttxt=-1; > &refresh; > } > ReadMode 0; > chop($input=<STDIN>); > $host->print("$input"); > &refresh; > } > > The next attempt fixes the logic, however it still STOPS REFRESHING while > waiting for input and I still run OUT OF MEMORY. Try using: use strict; and localizing your vars. > use Term::ReadKey; > > <----SNIP!----> > > sub refresh > { > $hosttxt=$host->getline; > if (length($hosttxt) > 0) > { > print "$hosttxt"; > $hosttxt=-1; > &refresh; > } > ReadMode 0; > chop($input=<STDIN>); > $host->print("$input"); > &refresh; > } Maybe something like this will work better (not tested): use strict; my $host = [ ... new telnet connection call with possible timeout ]; $host->errmode(\&errsub()); ... setup code for telnet sub errsub { print @_, "\n"; } sub refresh { while (1) { # sinple loop to check for telnet data and accept kybd reply my $hosttxt = $host->getline; if ($host->timed_out) { next; } elsif ($host->eof) { die "Lost connection\n"; } print "$hosttxt"; chomp (my $input = <STDIN>); $host->print($input); } } -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
