Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link Validation not working correctly

Status
Not open for further replies.

JoeM6

Programmer
Aug 5, 2000
53
0
0
US
gamecentral.20m.com
After connecting to my database, I use the following to make sure the links are working properly:

use LWP::Simple;

while(my ($id, $Name, $Cat, $Type, $Players, $Object, $GameURL) = $sth->fetchrow_array()) {

if(head($GameURL)){

} else {
print &quot;Not Working: $GameURL<br>&quot;
}
}

However, of the 430 links in my database, it says that 183 of them arent working. I know this isnt right because I test the links out myself and they work. I know this method is kind of simple, is there a better way to do this with more accurate results?



JoeM6
JPMJR11@aol.com
 
I am a novice at this but I am reading quite a bit about LWP at the moment - I don't think you can always rely on the header info... it's not always supported by the servers as far as I understand. If the header specifically states that there is no problem then you can act upon this but sometimes no value is set and this appears as if there is trouble when there might not be.

It works as follows (in list context):-

(content_type, document_length, modified_time, expires, server)
= head(url);

so the code might appear:-

my ($type, $length, $mod) = head($url);

unless (defined $type) {
print &quot;Couldn't get $url\n&quot;;
}


Hope this is of some help...

Cheers
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top