Bennco99 has asked for the wisdom of the Perl Monks concerning the following question:
The 'for' statement works, but am unable to get the user_status_file.$user created.open (TEST,">>c:/temp/argtest6.txt") or die "Failed to open argtest.tx +t 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 f +ile"; @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 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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I create a file based on a variable?
by Corion (Patriarch) on Aug 03, 2006 at 14:16 UTC | |
|
Re: How do I create a file based on a variable?
by Fletch (Bishop) on Aug 03, 2006 at 14:18 UTC | |
|
Re: How do I create a file based on a variable?
by ptum (Priest) on Aug 03, 2006 at 14:22 UTC | |
by Bennco99 (Acolyte) on Aug 03, 2006 at 14:39 UTC |