$lastGood = time(); while( 1==1) { #print "."; #print time(), "\t", $lastGood, "\n"; if ((time() - $lastGood) > 300) #if it has been 5 minutes since the last check, check again { #do something $lastGood = time(); } }