$times = 2; $minutes_threshold = 7200; $now = time(); $oldest_time = $now - ($minutes_threshold*60); $user_status_file = "C:/temp/perl_logs/user_status.$user.txt"; open (USF, ">>", $user_status_file) or die "Failed to open User Status File file: $!"; @lines = ; close USF; # Now, read through the lines of the file from last (most recent) to first (oldest) # and see if n times occured in the last m minutes. for ( $i=$#lines; $i>=0; $i-- ) { $timestamp = $lines[$i]; chomp $timestamp; last if ( $timestamp < $oldest_time ); $count++; } if ( $count > $times ) { print ADL "User exceeded threshold! $count \n"; } print USF "$now\n"; close USF;