Take a look at the code I pasted below. It extracts URLs from a MySQL database and uses LWP::Simple to check their validity. If the link is down the script makes a note of it by updating the "valid" column of the db.

I'd like to set a timeout so that each time LWP goes out to check a link if it can't determine 'works' or 'broke' in 20 seconds is will consider the link invalid. I messed around with Perl's alaram() function but didn't have any success. Can anyone help?

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#!/usr/bin/perl

use LWP::Simple;
use DBI;

$db_database = "mp3db";
$db_uid = "root";
$db_pwd = "hn0fstfu";

$dbh = DBI->connect ("DBI:mysql:$db_database".$mysqlsock, $db_uid, $db_pwd) or die("could not connect to dbn");
$sth = $dbh->prepare("SELECT url FROM files");
$sth -> execute();
$numrows = $sth->rows;

for ($i = 0; $i = $numrows; ++$i) {
$url = ($sth->fetchrow_array);
if((head($url)) or (get($url))) {
$validity = "works";
} else {
$validity = "broke";
$valid_update = $dbh->do("UPDATE files SET valid = valid + 1 WHERE url = '$url'");
}
print "$validity - $urln";
}
[/code]

[This message has been edited by scream (edited September 09, 2000).]