Sounds to me like Joost had the right idea: Try File::Tail. That would allow you to read the whole file in at startup, scan it for the last header line, and then just pick up the new lines (data or header) as they're added instead of repeatedly reading and processing the entire file. | [reply] |
just dave:
I was thinking that by using a single string rather than an array, you can avoid the explicit looping, making your code clearer. Since you also mentioned having a memory leak, I thought that a single string would fragment memory much less than a bazillion smaller strings. That might make it easier for perl to reuse the memory and/or recognize what can be freed
Other than that, it's not much different at all.
Of course, since you're rereading the same file repeatedly, I think that Joost's suggestion is my favorite so far. Then, while looking up File::Tail, I saw File::Tail::App, which is pretty cool because it does much of the grunt work for you.
--roboticus | [reply] |