in reply to Parse Log File As Written
One possible solution can be using Tie::File.
"Tie::File represents a regular text file as a Perl array. Each element in the array corresponds to a record in the file. The first line of the file is element 0 of the array; the second line is element 1, and so on. The file is not loaded into memory, so this will work even for gigantic files. Changes to the array are reflected in the file immediately."
You may write a program which runs every few ms or reside in the memory. One sample program can be
Hope this helps.#/usr/bin/perl $file = "my-log_file.log"; $o = tie @array, 'Tie::File', $file; $o->flock; # lock the file. See Note 1. $line_count = 0; while( 1 ){ if( $line_count < $#array ){ #New line is added $line_count++; foreach $line($line_count .. $#array ) { #### Your code to parse @array[$line];#### } $line_count = $#array; } sleep(1); #parse every second }
Notes :
Updates :
Cheers !
--VC
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse Log File As Written
by dsheroh (Monsignor) on Sep 24, 2007 at 14:44 UTC | |
by atemon (Chaplain) on Sep 24, 2007 at 17:34 UTC | |
by Cristoforo (Curate) on Sep 25, 2007 at 01:26 UTC | |
by dsheroh (Monsignor) on Sep 25, 2007 at 15:10 UTC |