HTTP::Request & HTTP::Response #!/usr/local/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; my ($ua, $res) = (LWP::UserAgent->new(), undef); # these two lines are equivilent $res = $ua->get('http://cnet.com/'); $res = $ua->request(HTTP::Request->new('GET','http://cnet.com/')); # but you can do a lot more with the Request object... my $req = HTTP::Request->new('GET','http://builder.com/foo'); $req->header(Accept => 'text/x-dvi, text/html, text/*, */*'); $res = $ua->request($req); # the Response object also contains a lot of usefull info... print "The Status code was: ", $res->code(), "\n"; print "The Content Type was: ", $res->header('Content-Type'), "\n"; print "The URL was: ", $res->request()->uri(), "\n"; while ($res = $res->previous()) { print "Redirected from: ", $res->request()->uri(), "\n"; }