Temporary filename

B

Bill H

I have seen the FAQ on creating a temporary filename, but is there
anyway of make them self-delete after a certain time period (probably
not, but you guys have done some amazing stuff with perl)?

Bill H
 
P

Paul Lalli

I have seen the FAQ on creating a temporary filename, but is
there anyway of make them self-delete after a certain time
period (probably not, but you guys have done some amazing stuff
with perl)?

What about alarm() and $SIG{ALRM} ?

perldoc -f alarm
perldoc perlipc

Paul Lalli
 
M

Martijn Lievaart

I have seen the FAQ on creating a temporary filename, but is there
anyway of make them self-delete after a certain time period (probably
not, but you guys have done some amazing stuff with perl)?

On *nix, delete the directory entry but keep the filehandle. The file
will be gone once you close the filehandle.

M4
 
B

Ben Morrow

Quoth Bill H said:
I have seen the FAQ on creating a temporary filename, but is there
anyway of make them self-delete after a certain time period (probably
not, but you guys have done some amazing stuff with perl)?

If you just want to make sure the file goes away when you've finished
with it, you can use the File::Temp module. Otherwise, please give more
details on what you are trying to accomplish; unless

system qq{sleep 5 && rm -f "$file" &};

does what you want. In general you will need to have a process hanging
around to remove the file for you.

Ben
 
B

Bill H

If you just want to make sure the file goes away when you've finished
with it, you can use the File::Temp module. Otherwise, please give more
details on what you are trying to accomplish; unless

system qq{sleep 5 && rm -f "$file" &};

does what you want. In general you will need to have a process hanging
around to remove the file for you.

Ben

I was having a hard time figuring out how to explain it, and realized
that what I need to do has to be done in the software, ie creating the
temporary file (a jpg image) and then deleting that one and creating a
new one (with a new name) when things change, while keeping track of
what file is "current" in a different file (in this case an XML). I
was hoping to have some way of having the old, replaced, unused files
(with obsolete filenames) "go away" on their own but I suppose a file
system hasn't progressed to the point of being able to use it like
memory where you "allocate" a block of memory and when done using it
you can "unallocate" it and it "goes away".

Bill H
 
B

Ben Morrow

Quoth Bill H said:
I was having a hard time figuring out how to explain it, and realized
that what I need to do has to be done in the software,

Is 'the software' your Perl program or some other program it is trying
to cooperate with?
ie creating the temporary file (a jpg image) and then deleting that
one and creating a new one (with a new name) when things change, while
keeping track of what file is "current" in a different file (in this
case an XML).

Note that you don't have to change the name: you could simply overwrite
the old file.
I was hoping to have some way of having the old, replaced, unused
files (with obsolete filenames) "go away" on their own but I suppose a
file system hasn't progressed to the point of being able to use it
like memory where you "allocate" a block of memory and when done using
it you can "unallocate" it and it "goes away".

Err... yes, it has, it's just 'free' is spelled 'unlink' (and you can't
create dangling pointers) :).

If you want any useful help you will need to start from the beginning
and explain what you're doing and why it's not working, preferably with
(short!) examples of pieces of code that aren't doing what you want.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,808
Messages
2,569,686
Members
45,452
Latest member
AmberLayde

Latest Threads

Top