in reply to Re: Automatically creating incremental file names
in thread Automatically creating incremental file names
Note you output two identical names: 1054051487.010345, not a good trait for making unique filenames. You're at the mercy of the platform's performance if you depend on timestamps alone. Combining the value with something else that's dynamic, such as a PID and/or a simple $counter++ is preferable, but still weak.
To really pick unique symbols, you should look for GUID or UUID generators, that's what they're for. A thousand machines running side by side won't even be able to pick the same symbol twice. Data::UUID seems useful.
If you want unique temporary filenames, please look for modules that do this. File::Temp for example. These often handle file cleanup too.
Simple timestamps, counters, and -e checks may introduce new race conditions only discovered when you try to scale up to a few hundred or thousand independent concurrent tasks. Don't reinvent the wheel, just to rediscover the limitations of a naive approach.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Automatically creating incremental file names
by BrowserUk (Patriarch) on May 27, 2003 at 18:04 UTC |