Worth contemplating (monks should be contemplative) before it happens, are the consequences of rerunning the command, or having the machine crash in the middle of a run. If you plan to run it many times, note that you are adding a couple extra ## characters to the line each time you run. Perhaps you want to defend against that.
If something interrupts a run, what happens if you rerun the command? A downside of the i perlrun flag is that it backs up before the run and overwrites the file with the original name. If you crash, you can restore the file to something sane from the backup copy. But if you fail to do so before another run, you'll use the partially complete original file, and destroy the valid backup. I prefer to preserve the original until everything is complete, then rename to update it as atomically as possible. But always check the results of opening and closing the temporary file, and don't do the rename if there was any problem.
In reply to Re: Help in read and write to file at a same time in same file.
by jpl
in thread Help in read and write to file at a same time in same file.
by gskoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |