#!/usr/bin/perl -w
use IO::Socket;
my $sock = new IO::Socket::INET (
                                 PeerAddr => '127.0.0.1',
                                 PeerPort => '7070',
                                 Proto => 'tcp',
                                 );
die "Could not create socket: $!\n" unless $sock;
#print $sock "Hello there!\n";
# while(<STDIN>)
# {
#     print $sock $_;
# }
open(FIC, 'alire.txt') || die 'pb ouverture fichier alire.txt';
$lu="Go Go Go";
while($lu ne "CLOSE")
{
    sleep(1);
    if (!-z 'alire.txt') # Attention aux quotes utilisées !!!!!
    {   @lignes = <FIC>;
	$lu = shift @lignes;
        chomp($lu);
        close(FIC);
        open(FIC, '>alire.txt');
	print FIC @lignes;
        close(FIC);
	open(FIC, 'alire.txt');
	print $sock "$lu\n";
    }
}
close(FIC);
close($sock);
