in reply to Filenames based on timestamp

Assuming this is not time-critical on the file creation (which I don't know to be a valid assumption, from the way you talk), the best idea I can see is something like this- get the timestamp, check for a file by that name, and if there is one that exists, increment some form of counter to be added to the name until no such filename exists. A possible code snippet might look like (forgive the rough code, but this was as I was thinking out the issue, and has not been tested):

# filename format: filename-timestamp-counter.txt # assumption: $ts contains timestamp in unix time format # (seconds since epoch) # assumption: $filename created earlier with 'my', # and will contain the filename at end my @fnp = ('file', $ts, 0); $fnp[2]++ while (-e join('-', @fnp)); $filename = join('-', @fnp) . '.txt';

YMMV. I am sure others may have additional suggestions, and I look forward to hearing them as well.