in reply to Writing to files
This is the "general solution" mentioned in the above link. It has the advantage of not using much memory, as you only have to store one line at a time in memory, instead of the whole file. It has the disadvantages of using a temporary file, making the renaming system calls, not working well with file locking, and not being able to work with the data as easily, although you can always read in the whole file (@myfile = <ODLFILE>) at the cost of the memory advantage mentioned above.
This method has the disadvantages of reading the whole file into memory, and perhaps being harder for those not familiar with seek and truncate. The advantages are not using a temporary file, not having to rename, and a better ability to make non line-by-line changes. It's also the best way to do it if you are file locking.
I prefer the second way myself, but whatever floats your boat - as long as it gets the job done!
|
|---|