in reply to detect redirect

I think that's available from the response object returned. The lwp-request script has a -S option that shows the info; take a look and see what it does.

Update: it does:

$response = $ua->request($request); ... my $method = $response->request->method; my $url = $response->request->url->as_string; my $code = $response->code; print "$method $url --> ", $response->status_line, "\n";
(only it does the last 4 lines depth-first recursively, using $response->previous to look up earlier redirect $response's). Hmm, $code doesn't seem to be used anywhere there...