my $lasttime=from_db($userid); my $thistime=time; if ($thistime-$lasttime<(5*60)) { print 'online'."\n"; } set_db($userid,$thistime);