#!/usr/bin/env perl use strict; use warnings; use IO::Socket; my $client = IO::Socket::INET::->new( Proto => 'tcp', PeerAddr => 'localhost', PeerPort => 55555 ) or die "Client can't connect: $!"; my $max_iterations = 3; my $sleep_time = 10; for (1 .. $max_iterations) { print $client qx{ls -al 2>&1}; sleep $sleep_time; }