Debugging Mech,LWP...
Here is a good way to debug request->responses that are going between LWP and the web server.
use Aspect;
my $pcut = call qr/LWP::UserAgent::send_request/;
before {
my $ctx = shift;
print "req================\n";
print $ctx->params->[1]->as_string;
} $pcut;
after {
my $ctx = shift;
print "resp----------------\n";
print $ctx->return_value->headers->as_string;
print "==================\n";
} $pcut;
use WWW::Mechanize;
my $m = WWW::Mechanize->new;
$m->get("http://www.google.com");
req================
GET http://www.google.com
Accept-Encoding: identity
User-Agent: WWW-Mechanize/1.14
resp----------------
Cache-Control: private
Date: Wed, 16 May 2007 17:08:09 GMT
Server: GWS/2.1
Content-Length: 3971
Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Wed, 16 May 2007 17:10:46 GMT
Client-Peer: x.x.x.x:80
Client-Response-Num: 1
Set-Cookie: PREF=ID=f76dcf3c38b51e16:TM=1179335289:LM=1179335289:S=WLL
+o_3xLrawI8ife; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=
+.google.com
Title: Google
==================
You can use $c->return_value->as_string, if u want to get the content of the response too. And of course you need to install Aspect.pm module ;)