#!/usr/bin/perl
##################################################
# japc.pl --Mike Schilli, 2001 (m@perlmeister.com)
##################################################
use warnings;
use strict;

my $H = "localhost";
my $P = 9000;

use IO::Socket;

my $socket = IO::Socket::INET->new("$H:$P") or
    die "Cannot open $H:$P";

my $intro = $socket->getline();

while(<DATA>) {
    print "... adding $_";
    $socket->print("add $_");
}

$socket->print("exit\n");
my $r = $socket->getline();
print "$r\n";

__DATA__
Hallo, wie geht's? - Hajimemashite!
Mein Name ist Mike - Mike to mooshimasu.
Schönes Wetter, nicht wahr? - Ii ten'ki desu nee.
Bis nächste Woche! - Mata raishuu.
