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


in reply to RE: RE: Writing to files
in thread Writing to files

Not to put words in his mouth, but the point I think japhy (right?) was trying to make was that, if the reason you're writing to the beginning of the file is that you think that there's where you should store the most "recent" information, then there's really no point.

Just keep your file in chronological order (oldest at beginning, newest at end) and, when you're reading the file into memory, use unshift rather than push so that the newest data ends up at the beginning of the array.

Which definitely makes sense, and makes the problem quite a lot less complicated, if that's the reason the op wanted to write to the beginning of the file.

Replies are listed 'Best First'.
RE: RE: RE: RE: Writing to files
by japhy (Canon) on Apr 09, 2000 at 00:11 UTC
    Yeah, that was me. And you're correct -- there's no need to write to the TOP of a file, just so that it is in newest-to-oldest order. Use the append + unshift method. It's smarter.