in reply to Re^2: Time in Milliseconds or NanoSeconds
in thread Time in Milliseconds or NanoSeconds
The problem now is I am using timestamp in seconds and there could be more than one name generated in the same second with same user provided name.
How about using a simple incrementing number in this case? You can use sysopen to do this and avoid race conditions:
use Fcntl; my $username = "..."; my $filename = $username . time; my $inc = 1; my $fh; until (sysopen $fh, $filename.$inc, O_WRONLY|O_CREAT|O_EXCL) { $inc++; } print $fh time, "\n";
|
|---|