#!/usr/bin/perl use warnings; use strict; use IO::Socket qw(:DEFAULT :crlf); my $port = $ENV{CM_PORT} || 3013 ; my $host = $ENV{CM_HOSTS} || 'uksupu02' ; my $read ; my $quit ; my $utilprmpt = 'Testing> '; my $socket ; my $user_input = 'start' ; RERUN_PROMPT: while ( $user_input ne 'quit') { print "$utilprmpt"; chomp ( $user_input = <>); if (!$user_input){next RERUN_PROMPT } ; if ($user_input =~/^\s+$/){ next RERUN_PROMPT } ; if ( $user_input eq 'quit') { exit }; &CreateClient ; } sub CreateClient { $socket = IO::Socket::INET->new("$host:$port") or die "can't create socket: $!"; user_to_host ($socket, $user_input) ; &host_to_user ($socket); } sub user_to_host { my $sock = shift; my $msg = shift ; print $sock $msg ,CRLF; } sub host_to_user { my $sock = shift ; my $nread ; my $inp ; $/ = CRLF ; while (<$sock>) { chomp; my @data = split/-/, $_ ; print $_ , "\n"; if ($data[1] eq 'THISISTHEEND') { return ; } } }