Bennco99 has asked for the wisdom of the Perl Monks concerning the following question:
$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 = <USF>; close USF; # Now, read through the lines of the file from last (most recent) to f +irst (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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: count lines, bottom to top
by davorg (Chancellor) on Aug 11, 2006 at 15:34 UTC | |
|
Re: count lines, bottom to top
by cdarke (Prior) on Aug 11, 2006 at 16:11 UTC | |
by Bennco99 (Acolyte) on Aug 11, 2006 at 16:24 UTC | |
by jdtoronto (Prior) on Aug 11, 2006 at 17:42 UTC | |
|
Re: count lines, bottom to top
by swampyankee (Parson) on Aug 11, 2006 at 16:34 UTC | |
|
Re: count lines, bottom to top
by Ieronim (Friar) on Aug 11, 2006 at 17:59 UTC | |
|
Re: count lines, bottom to top
by sh1tn (Priest) on Aug 11, 2006 at 17:28 UTC |