use IO::Socket; my $client = IO::Socket::INET::->new( Proto => 'tcp', PeerAddr => 'localhost', PeerPort => 55555 ) or die "Client can't connect: $!"; my @msgs = qw(msg1 msg2 msg3 msg4 msg5); for (@msgs) { print $client "$_\n"; sleep 1; }