#!/usr/bin/perl use strict; use Pod::Usage; use Getopt::Std; our $received; our $PORT; my $x; our $ob; my $gotit; my $found; my $end; my $obattern; my $instead; my $timeout; my $thread4; sub Receive{ $x=1; # this remains from the not Tk version print "\n\t"."-"x32 ."\n"; print "\tRECEIVING LINES FROM OTHER PARTY\n"; print "\t"."-"x32 ."\n"; while(1){ $received = ReadPort($PORT, 5); if($received ne ""){ print "\t$x\tRX>\t$received\n"; $ob->write("Sent back by my script> ".$received."\n"); $x++; } } print "\n"; print ""; sub ReadPort{ # Store timeout time in millisecond tic $timeout = $ob->get_tick_count + (1000 * $timeout); $ob->lookclear; # Clear lookfor buffers $gotit = ""; while(1) { # polls until we have a line of data return unless ( defined ($gotit = $ob->streamline) ); if ($gotit ne "") { ($found, $end, $obattern, $instead) = $ob->lastlook; return "$gotit"; } # or an error return if ($ob->reset_error); if ($ob->get_tick_count > $timeout) { my ($match, $after, $obattern, $instead) = $ob->lastlook; return ; } } } } 1;