I'am not sure how real your sample is, but for this kind of work I usually use WWW::Mechanize which gives you a really nice high level interface to HTTP::Request, HTTP::Response and LWP::UserAgent.
WWW::Mechanize also has a nice interactive shell and even a http proxy server HTTP::Recorder for recording scripts.