Sprad has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a web app that needs to dynamically generate temp files for users to download. How is this sort of thing typically handled? There are a couple concerns that I can think of:

* The files need unique names
* The files shouldn't stick around any longer than necessary

I have a session ID, so I can base a reasonably unique filename off of that. But the file expiration has me going in circles. Is there a better way than simply dumping them all in a temp directory and setting a cron job to sweep the old ones?

A fair fight is a sign of poor planning.