P is for Practical | |
PerlMonks |
Re: Parse Log File As Writtenby alanonymous (Sexton) |
on Sep 25, 2007 at 03:01 UTC ( [id://640854]=note: print w/replies, xml ) | Need Help?? |
I've been playing around and testing for a while now ... What I've learned: File::Tail does NOT work for Win32 systems. The Tie::File method seems like it could work but I'm having problems with the code: 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. Thanks for all the help ... I don't know why but I always seem to make things difficult, and I might be going a bit crazy! -Alan Edit:Is Tie::File capable of watching changes to the file in realtime? I've noticed in the docs that the file updates as soon as the array is modified and written, but does the array update if the file is updated? Edit 2:It seems that the $#array never updates to reflect the current number of lines in the file, without flock. With flock the file never updates so I can't determine if $#ever would update.
In Section
Seekers of Perl Wisdom
|
|