mark van... wrote:
I am writing some blog software, but I can't figure out how to write to the beginning of a file, because when I print to the file it always goes at the end. Also, I don't want to overwrite the existing text in the file, I want to insert the new text.


Well you can do it the verbose and systematic way:

open file for reading
read in all lines
close file for reading
open file for writing
print your new line
print all old lines
close file for writing...

or check out one of the other approaches,

perldoc -q "append to the beginning"

Or you could open the old file for reading, write to a new file by buffereing rather than storing the whole file in memory, then close the new file and move it to the location of the old file....etc, etc.

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to