in reply to How do I write a simple webserver

How about starting a layer higher and building your webserver ontop of the HTTP::Daemon module?
use HTTP::Daemon; use HTTP::Status; $d = new HTTP::Daemon; print "Please contact me at: <URL:", $d->url, ">\n"; while ($c = $d->accept) { $r = $c->get_request; if ($r) { if ($r->method eq 'GET' and $r->url->path eq "/xyzzy") { # this is *not* recommened practice $c->send_file_response("/etc/passwd"); } else { $c->send_error(RC_FORBIDDEN) } } $c = undef; # close connection }