Unless reads from this file are considerably more frequent than writes, reading the whole file and then re-writing it with the new stuff at the top in order to speed up reads will have dubious benefit.
If the reads and writes are paired (equal numbers of each) then one cycle of 'Writing to the end of file + reading the whole file to get the last line' compares favourably with 'Reading the whole file, writing the new line and then re-writing the whole file + reading the first line'.
You would almost certainly be better of writing new stuff to the end, and then using File::ReadBackwards or a similar technique to retrieve it.
In reply to Re: writing to the top of a file
by BrowserUk
in thread writing to the top of a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |