use URI::Escape;
my $location = "http://www.google.com/sorry/?continue=http://www.google.com/search%3Fq%3Dperlmonks";
my $new_location = $location;
$new_location =~ s/.*\/sorry\/\?continue=(.*)/$1/;
$new_location = uri_unescape($new_location);
print " $location\n=> $new_location\n";
__END__
http://www.google.com/sorry/?continue=http://www.google.com/search%3Fq%3Dperlmonks
=> http://www.google.com/search?q=perlmonks
####
http://www.google.com/search?=perlmonks
####
if ($location =~ m|/webhp$|) {
my $new_location = "http://www.google.com/search?q=perlmonks";
$headers->header( Location => $new_location );
}