in reply to Parse Log File As Written
Basically, the program runs, and goes to the continuous loop as expected. The problem is that if the $o->flock; is there, the program won't update the log file, and even if I use a test text file and manually save the file, Windows won't allow it because another program has locked it. If I uncomment the lock (I'll never want to write to the log file, so is locking it even necessary?) then the loop never detects that the file is updated, which it is. I'm not familiar with the context used in the foreach loop in the example ... Will the '$line_count ... $#array' actually count in the @array if not specifically specified? Even going through all of @array upon a newline yields no output.#!/perl use strict; use warnings; use Tie::File; my $logfile = "blablalogfile.txt"; #my $logfile = "test.txt"; my $o = tie my @array, 'Tie::File', $logfile; $o->flock; my $line_count = $#array; while (1) { if ($line_count < $#array) { $line_count++; # foreach my $line (@array) { foreach my $line ($line_count .. $#array) { print $line; } $line_count = $#array; } sleep(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse Log File As Written
by duff (Parson) on Sep 25, 2007 at 04:09 UTC | |
|
Re^2: Parse Log File As Written
by dsheroh (Monsignor) on Sep 25, 2007 at 15:35 UTC |