Thanks for your reply. But I've a hard time understanding your code and how to implement it.
Please do me a flavor. Kindly edit my original script below with your implementation.
#!/usr/bin/perl
require 'myconfigure.cgi';
$timeout = 5;
use DBI;
$keywords = "Whether rocking natural-curls, a-short";
print "Content-type: text/html\n\n";
sub do_search {
$time1 = time;
$dbh=DBI->connect("dbi:mysql:$database:localhost","$username","$pa
+ssword");
$keywords_quoted = $dbh ->quote ($keywords);
$query="SELECT count(*) FROM $websites_table WHERE MATCH(title) AG
+AINST ($keywords_quoted)";
$sth=$dbh->prepare(qq{$query});
$sth->execute();
$total_count = $sth->fetchrow_array ();
$sth->finish;
$dbh->disconnect ||die("Couldn't disconnect to database!\n");
$time2 = time;
$time_ran = $time2 - $time1;
}
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm $timeout;
&do_search;
alarm 0;
};
if($@) {
$time2 = time;
$time_ran = $time2 - $time1;
print "$@, Time Ran: $time_ran, Total Count: $total_count\n";
exit;
}
print "Time Ran: $time_ran, Total Count: $total_count\n";
exit;
Thanks so much! |