in reply to if method is POST...

What you want may already have been done... check out perl-server.