On Mon, 09 Aug 2010, Ãvar Arnfjörð Bjarmason wrote: > > If we're set on adding perl -pi emulation on Windows it would probably > be best just to create a backup file with the equivalent of > File::Temp, and unlink it when we're done with it. The problem with using File::Temp for the backup file is that now we have to copy the data twice instead of once, which may be rather expensive for large files. > The only problem with that is that perl might run out of diskspace > when doing -pi on large files, or slowly accumulate garbage if it's > e.g. being killed before it gets around to the unlink(). Isn't the problem about running out of disk space the same on Unix? You also have both files on disk; you just don't have a filename for the old content. But the disk space for the old file still doesn't become available until the new file has been completely written. As for accumulating garbage, it would be possible to register the filename with the OS to delete it on the next reboot. I don't know if there is a mechanism to remove the file from that list once you successfully delete it though, so you may accumulate a huge list if you never reboot the machine. This mechanism is only meant for "installers" that can't update files that are currently in use, and these kind of programs would normally recommend or trigger a reboot at the end of their operation anyways. ExtUtils::Install is making use of this mechanism on Windows already (via Win32API::File). Cheers, -JanThread Previous