my $times = 2; my $minutes_threshold = 7200; my $now = time(); my $oldest_time = $now - ($minutes_threshold*60); my $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: $!"; # Now, read through the lines of the file # and see if n times occured in the last m minutes. my $count = 0; while ( ) { chomp $_; next if ( $_ < $oldest_time ); $count++; } if ( $count > $times ) { print ADL "User exceeded threshold! $count \n"; } seek USF, 0, 2; #go to the end of the file - maybe you can remove this line print USF "$now\n"; close USF;