http://www.perlmonks.org?node_id=492859


in reply to Re: Temp file strategy
in thread Temp file strategy

"Is it possible to not create the temp file until the user selects to download it...?"

Sure, just output your preferred filetype w/ proper MIME type just like you would a web page. Nothing fancy at all, and I've been known to do this.

"I don't think any of the temp file solutions written above will work across invocations of your CGI..."

Reread the above example. Files are deleted after an arbitrary "timeout". We do this alot for CSV downloads of reports where I work. Usually we do 24hrs. Sure, if someone runs a report, but doesn't click on the CSV link until sometime tomorrow the file will be gone. I don't think that's unreasonable, but it's really up to you how long the file sticks around.

Of course, these are hand-rolled solutions. I think I'm going to have to look into the File::Temp module folks keep talking about.