use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '80', Proto => 'tcp', Timeout => 10, ); die "Could not create socket: $!\n" unless $sock; while ($i < 5) { $i++; print $sock "sending the stuff $i\n"; print "sending the stuff $i\n"; sleep 2; } $sock->close(); sleep 20;