use IO::Socket::INET; my $socket; # for use in all scopes $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '1880', Proto => "tcp", Type => SOCK_STREAM) or die "Big Problem connecting to Server, Man : $!\n\n"; while (1) { print 'talk to me, like keyboards do: '; my $input = ; chomp $input; if ( $input =~ /^q/i ) { exit; } else { print $socket "$input\n"; } }