in reply to Get specific entries from a file which is always growing
A quick test shows that something like the following simple approach seems to work rather well (on a Unix file system, where you can read a file that's still open for writing):
open my $fh, "<", "growingfile" or die; while (1) { while (<$fh>) { print if /IDENTIFIER/; } sleep 1; }
I.e. you just resume reading after you've reached the (current) end of file.
The tricky part is probably when IDENTIFIER has only been partially read before EOF is encountered. To handle this case, you'd need to concat the last read incomplete record after resuming... (Whether this is relevant at all would depend on the buffering mode used to write the file (i.e. unbuffered, line-buffered, fully/block-buffered), and what your input records are (e.g. lines).)
|
|---|