in reply to Perl Socket (to mimic PHP code)

I would suggest you use LWP::UserAgent for this; it provides a higher-level interface to HTTP.

For this problem, look into HTTP::Request for info on to craft your own request bodies.