http://qs321.pair.com?node_id=464363


in reply to Reopen file when contents changed?

I am not sure if it would work but couldn't you just create a pointer to the first line of the file when you initially read it in and just leave it static?

Replies are listed 'Best First'.
Re^2: Reopen file when contents changed?
by chb (Deacon) on Jun 08, 2005 at 10:22 UTC
    Huh? Pointer? static? What are you talking about?
      When you open a file you have a pointer that points at the first line of the file. So I was just suggesting the OP might want to try just dupelicating that pointer and not changing what it points to while the original file pointer loops through the rest of the lines of the file reading in the data. I am slightly new to perl not sure if it would work. Hence it would be a static pointer, one that does not change, which is all the OP needs a constant pointer to the first line of the file. This would only be usefull if he isn't adding any information to the top of the file because the pointer would then not be pointing to the correct line.
        I think there was a misunderstanding. The combination of the words 'pointer' and 'static' made me think of a c-style static pointer, a thing that simply does not exist in perl. You are right, you would need something that addresses the beginning of the file. But that would be a fileposition, which is always 0 for the beginning of a file (kind of static...), so there is no need to store anything.