use IO::Socket::INET; $socket = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => '20000', Proto => "tcp") or die "Couldn't connect to $remote_host:$remote_port : $!\n"; $sitedata = "C:\\Program Files\\Frey Technologies\\SageTV\\current.info"; $count =1; # read the remote answer, open(DAT,">$sitedata") || die("Cannot Open File"); while(1) { $answer = <$socket>; print $answer; @parsed= split (/: /, $answer); ## sometimes shows ":" are parsed out, this puts it back if($parsed[2]) { print DAT "$parsed[1] : $parsed[2]";} else { print DAT $parsed[1];} $parsed[2]=""; if($answer =~ /recording_1_endtime:/) { close (DAT); sleep 5; open(DAT,">$sitedata") || die("Cannot Open File"); print $socket "\n"; } } # and terminate the connection when we're done. close($socket);