use strict; use IO::Socket; my $server = IO::Socket::INET->new ( Proto => "tcp", LocalPort => 3000, Reuse=>1, Listen=>10 ); my ( $pid, $host, $date ); $date = scalar localtime(); sub spawn_srvr { my ( $vers, $page, %hdrs ); while (<$host>) { /^(GET)\s(.*)/ && do { $hdrs{$1} = $2; next; }; /^((\w|-)+):(.*)/ && do { $hdrs{$1} = $3; next; }; /\n/ and do { ( $page, $vers ) = split(/\s/, $hdrs{'GET'}, 2); if ( open(FH, "<$page") ) { print $host < ); } else { print $host < 404 Not Found

Not Found

The requested URL $page was not found on this server.

EOF } last; }; } kill(9, $pid) && print "killed pid: $pid\n"; } while () { $host = $server->accept(); if ($pid = fork()) { spawn_srvr(); } $host->close; }