fusiondog has asked for the wisdom of the Perl Monks concerning the following question:
The situation:
60G HD, 40G file. No room to redirect standard out to a new file and/or make a backup. I thought, perl -i of course, but I get a counter point from a coworker that he believes it will still require extra disk space like sed -i. I've found an old article by merlyn from '98 that has an algorithm for "in place" that keeps a read pointer ahead of a write pointer in the same filehandle and then at end of the file, either truncate (and presumably in the perfected algorithm) concatenated to the end of the file as needed. And in my experiments adding a sleep to a perl -p -i -e, I see that the file size is set to 0 and no temp file is created in the working directory. Also in perldiag the following line strongly indicates that this is what is happening on on dos systems at least:
Can’t do inplace edit without backup
(F) You’re on a system such as MS-DOS that gets confused if you try reading from a deleted (but still opened) file. You have to say
"-i.bak", or some such.
---
Seems like I'm right, but I can't find any implementation details that explicitly confirm that. Can anybody confirm?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Inplace without backup uses no extra disk space?
by BrowserUk (Patriarch) on Feb 02, 2010 at 07:00 UTC | |
by bellaire (Hermit) on Feb 02, 2010 at 14:27 UTC | |
by BrowserUk (Patriarch) on Feb 02, 2010 at 14:53 UTC | |
by marto (Cardinal) on Feb 02, 2010 at 15:18 UTC | |
by bellaire (Hermit) on Feb 02, 2010 at 18:29 UTC | |
by marto (Cardinal) on Feb 02, 2010 at 18:41 UTC | |
Re: Inplace without backup uses no extra disk space?
by ikegami (Patriarch) on Feb 02, 2010 at 16:01 UTC |
Back to
Seekers of Perl Wisdom