while(my $connection = $server->accept){ my $name = $connection->peerhost; my $port = $connection->peerport; if (my $pid = fork){ close $connection; next; # on to the next connection }else{ # child process - handle connection print $connection "You're connected to the server!\n"; while (<$connection>){ use HTTP::Date; my ($date, $time) = split(" ", HTTP::Date::time2iso()); my ($hour, $min) = split(":", $time); open (my $log, '+>>',"../../home/freetrac/public_html/logs/$port $date.txt") || die "Couldn't open log.txt: $!"; print $log $_; close $log; exit(0); } $connection->shutdown(SHUT_RDWR); exit; } }