http://qs321.pair.com?node_id=90794

bwarn has asked for the wisdom of the Perl Monks concerning the following question:

I'm checking to see if a site exists (I'm using LWP::UserAgent), is up, etc. before directing a user to a site. Unfortunately, if the destination site itself redirects users with a query (i.e., uses ? in the URL), my program bombs.

Does anyone have any suggestions how to successfully follow redirects?

$ua = new LWP::UserAgent; $request = new HTTP::Request('HEAD', "$URLVAL{URL}"); ($response) = $ua->request($request); if ($response->is_success) { print "Location:$URLVAL{URL}\n\n"; # quits if destination site redir +ects using '?' [or encoded equivalent] in its redirection script } else { # send user to another cgi that displays some 'failed URL' text. }

Originally posted as a Categorized Question.