in reply to Commands for IO::Socket

Use HTTP::Demon As mr Merlyn says it does everything that you want (and much of what you have already done) specifically if you look at the example on the web page here you will see code sample that does what you want I reproduce it below, slightly modified.
use HTTP::Daemon; use HTTP::Status; my $d = new HTTP::Daemon; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET' and $r->url->path eq "/aaa.mp3") { $c->send_file_response("aaa.mp3"); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
Remember next time tho to look for a wheel before you build one. *grins* good coding.
--

Zigster