darren chamberlain <[EMAIL PROTECTED]> writes: > * Frank D. Cringle <[EMAIL PROTECTED]> [2002-07-07 14:10]: > > Mark Fowler <[EMAIL PROTECTED]> writes: > > > File::Temp? It's core too... > > > > File::Temp is concerned with creating and opening temporary files. I > > was thinking of something that does that in a given directory and > > returns a magic filehandle (objectified?, tied?) that renames the file > > when it is closed and that deletes the file if the process terminates > > before it is closed. > > This is an interesting idea. Hmmm... > > package IO::MagicFile;
Apologies for continuing this on the templates list. It should probably move elsewhere. I think there has to be an explicit close method that checks for success and only then renames temp to target. Otherwise the target should remain unchanged. DESTROY would unlink temp (if it is still around). DESTROY doesn't run if the process dies from a signal. Maybe the AtExit module could handle that. Your version creates the temp file in /tmp (or wherever tmpnam chooses). The idea is to have it in the same directory as the target file, so that the rename happens with a single write to the directory. You also seem to be missing an ISA or base(), because the returned handle does not know how to print, at least in the non-sysopen case. You need to open $tmpnam rather than $file there, too. I think the aim should be to create a tied filehandle, so that the only change to a program that uses this module would be to the open statement (+ a USE statement). -- Frank Cringle, [EMAIL PROTECTED] voice: (+49 7745) 928759; fax: 928761
