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

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

I'm looking for help/suggestions as well as just trying to get this out of my head and see how bad my logic is for this problem.

Basics:
I have a set of .html and flash files in a directory. I want to sell access to these files for a nominal amount for 24 hours. The purchaser will receive an email and purchase confirmation page that will have a URL to access the files for the limited amount of time. I already have a perl script in place to deal with the purchasing.

Problem:
I need to figure out how to generate the random URL string and then expire it after a certain amount of time. This is not a random filename problem, this is a random directory name problem. I also need to figure out where to store the random directory name value so I can access it within the purchasing script (which handles more than just these URL's for sale).

Initial Thoughts:
I will have all the files in a directory and with a cron, I'll run a script to mv the directory to a new directory name every so often. This where the logic gets weird. Because if a person buys the item at 11:59pm on 11/14 and the cron runs at 12:01am on 11/15, then they'll immediately lose access, which doesn't work. There is the thought that we tell the user its only available for 24 hours, but its really available for 48 hours, but then I guess I'd need to have 2 set of files and keep track of which one is still valid to be "sold". And here is where my head starts to explode.

Environment
As a note, I'm doing this on an aging system running v.5.004_04 and while I have most basic modules, adding new ones aren't really an option. If someone suggestions one, I'll gladly look to see if it is installed. The last two times I've tried to have new modules installed it took 3 months and the "unix admins" horked up my 5.6 install (which is why I'm back to the older version). The deadline for this is less than 3 months. I also have no real database to access beyond text files. Thankfully, I am getting a new tasty server running linux and a current version of perl soon. But it still isn't here, so I must continue to toil in an environment from 1998 for now.

Please ask me many questions and point out obvious things that I am not thinking about. I just need other views on this problem.