http://qs321.pair.com?node_id=291821


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)...

my %idcount; my @ids; for (0..5){ my $t=time(); push @ids, $t."-".++$idcount{$t}; }
...resulting in "12345678-1","12345678-2" etc.

Cheers, Ben.