in reply to Re: Design/Style question about writing to a file from different functions
in thread Design/Style question about writing to a file from different functions
Thank you very much for your answers.Now I'm sure that solution 1 is the better solution.
As the author of a perl script my goal is it that it runs on a computer with much and less memory. So I do not know how much memory I have. But to give you numbers. sub_func1 writes about 50MB to the output file and sub_func2 writes about 150MB to the output file.
Do you think that holding about 200MB in memory is ok and then writing everything to the output file in one swoop? Or the other alternative would be to write first 50MB to the file and then 150MB. How many MB do you usually collect in memory if you want to use it on different computers?
Now to the reason why I want to move a line directly after building a part of the file. I'm computing a checksum which I know when sub_func1 finished. But the line with the checksum has to be at the beginning of the file and NOT at the end. My problem was that I thought that it is better to write everything directly to the file and that it is not ok to collect everything in memory. That's why I had the problem to move a line afterwards. If the memory solution is ok, then everything gets easier. Only main_func will then write to the file and the helper functions collect everything in memory.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Design/Style question about writing to a file from different functions
by BrowserUk (Patriarch) on Jul 20, 2010 at 21:50 UTC | |
|
Re^3: Design/Style question about writing to a file from different functions
by AndyZaft (Hermit) on Jul 20, 2010 at 20:31 UTC |