#!/usr/bin/perl -w

# server1.pl

use strict;
use IO::Socket;

my $server = IO::Socket::INET->new(
	LocalPort => 8080,
	Type => SOCK_STREAM,
    Reuse => 1,
    Listen => 5) or die "$@\n";

my $client;
     
while ( $client = $server->accept()){ 

    my $client_headers;
        
    while(<$client>){
        last if /^\r\n$/;
        $client_headers .= $_;              
    }

    print $client "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";    

    $client_headers =~ s/\r\n/<br>/g;

    print $client $client_headers;   

    close($client);
}	