in reply to Perl Socket (to mimic PHP code)
For this problem, look into HTTP::Request for info on to craft your own request bodies.