It will be better if this solution is based on HTTP protocol.
Checkout HTTP::Daemon in CPAN. It will give you the basics of a server. You can then over-ride methods to handle your HTTP.
Alternatively, try HTTP::Server::Simple although that module doesn't seem as mature as the first one.
Finally, you could take a look at Net::Server, which is a more general approach.