in reply to if method is POST...

Essentially, you: Take a look at HTTP::Daemon. You can either use the module or take a look at how it works, to see how you can write your own server.