open (TEST,">>c:/temp/argtest6.txt") or die "Failed to open argtest.txt file"; # Configure the number of times and the time window using the # following two variables. $times = 5; $minutes_threshold = 30; # Parse the command line parameter - should be the user name $count = 0; foreach $element (@ARGV) { #print TEST "$count,$element \n"; $count += 1; } $raw_user = lc ("$ARGV[7]"); my $user; if ($raw_user =~ /^(\w+)/) { $user = $1; } print TEST "$user\n"; $now = time(); #this line works $oldest_time = $now - ($minutes_threshold*60); #this line works $user_status_file = "C:/temp/user_status.$user"; 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 occurred in the last m minutes. for ( $i=$#lines; $i>=0; $i-- ) { $timestamp = $lines[$i]; chomp $timestamp; last if ( $timestamp < $oldest_time ); $count++; } print USF "$now\n"; rint USF "$now\n"; close USF; close TEST;