in reply to Checking URLs with LWP::UserAgent
Your problem is that you're single-quoting '$whereto' which tells Perl to literally use $whereto which is not a valid URL. Put it in "double quotes".
Also, if all you're interested in is whether or not the URL is "OK" (i.e. giving a 200-series response), consider using HEAD instead of GET, and verify the response is "good" with is_success like you're doing. HEAD will return the same HTTP response but without retrieving content. Properly written CGI scripts, for instance, can avoid having to do a lot of unnecessary work with HEAD requests if all you're interested in is a success/failure. At a minimum you're saving bandwidth.
It might do you good to print out the $res response, so you know why it failed.
|
|---|