in reply to Use time() to create unique ID
There are many ways round this without having to resort to a sleep - the most obvious being Time::HiRes, which (although system-dependant) will give you a much higher resolution than time().
Another way is to add a counter variable, something like (untested)...
...resulting in "12345678-1","12345678-2" etc.my %idcount; my @ids; for (0..5){ my $t=time(); push @ids, $t."-".++$idcount{$t}; }
Cheers, Ben.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Use time() to create unique ID
by graff (Chancellor) on Sep 17, 2003 at 05:43 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2003 at 07:16 UTC |
In Section
Seekers of Perl Wisdom