in reply to Automatically creating incremental file names
My suggestion would be to use the time function from Time::HiRes.
That should give you a unique time (to the microsecond if your platform supports it), and should be okay until something like 2038?use Time::HiRes qw[time]; printf "%.6f\n", time for 1..10; 1054051486.970288 1054051486.980302 1054051486.990316 1054051487.000331 1054051487.010345 1054051487.010345 1054051487.020360 1054051487.030374 1054051487.040388 1054051487.050403
Update:
The timestamp is only a starting point.
If you are creating your temp files on shared media (suggestion:Don't!), or if you are running on a multi-processor machine, then you would need to combine the timestamps with additional information to aceive uniqueness. Processor ID in the latter case would work.
In the former case, which I would advise against, but if you have access to the hardcoded MAC addresses, this is a good starting point.
A bonus is that the resultant filenames are easily compared so cleaning up the directory periodically should be trivial.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Automatically creating incremental file names
by halley (Prior) on May 27, 2003 at 17:39 UTC | |
by BrowserUk (Patriarch) on May 27, 2003 at 18:04 UTC | |
|
Re: Automatically creating incremental file names
by Abigail-II (Bishop) on May 27, 2003 at 18:19 UTC | |
by BrowserUk (Patriarch) on May 27, 2003 at 18:34 UTC |