develooper Front page | perl.perl5.porters | Postings from August 2010

RE: What do we do about perl -pi on Windows?

Thread Previous
From:
Jan Dubois
Date:
August 9, 2010 16:36
Subject:
RE: What do we do about perl -pi on Windows?
Message ID:
046a01cb381b$a866c150$f93443f0$@activestate.com
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,
-Jan



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About