Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I parse an active log file?

Status
Not open for further replies.

goliath

MIS
Aug 18, 1999
62
US
Hello,

I'm looking into how to parse an active log file. It does not seem to be locked open - but is appended to.

I would like to be able to parse the file as new lines are added.

I've read and parsed in-active files, that ends once it reaches the end tho.


Thanks!
 
This from the Perl Cookbook:

Read until the end of file. Sleep, clear the EOF flag, and read some more. Repeat until interrupted. To clear the EOF flag, either use seek:

for (;;)
{
while (<FH>) { ... }
sleep $SOMETIME;
seek (FH, 0, 1);
}

or the IO::Handle module's clearerr method:

use IO::Seekable;

for (;;)
{
while (<FH>) { ... }
sleep $SOMETIME;
FH->clearerr();
}

______________________________________________________________________
Did you know?
The quality of our answers is directly proportional to the number of stars you vote?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top