Dunx has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way of getting a timestamp value resolved to less than a second?

I've been using time, but that only produces times to the nearest second, which is pretty coarse these days.

The reason I ask is that I'd like a sequential GUID value for user input from a web form which doesn't involve using a single file to hold next value (cf the flock example in the Perl Cookbook) - using the posting time seems like a sensible, bottle-neck free, approach.

Dunx

Replies are listed 'Best First'.
Re: Sub-second Timing in Timestamps
by httptech (Chaplain) on Mar 14, 2000 at 23:10 UTC
    use Time::HiRes qw(gettimeofday); $time = sprintf("%d%06d", gettimeofday());
Re: Sub-second Timing in Timestamps
by turnstep (Parson) on Mar 24, 2000 at 23:57 UTC

    Why does sub-second response time matter for user input? Does it really matter who posted something "first" to within a hundredth of a second? If not, consider using time (to the nearest second) plus something like the current process ID. That should take care of any collisions:

    $GUID = "$^T$$";

    Not sequential, but do you really need it to be?

RE: Sub-second Timing in Timestamps
by Anonymous Monk on Mar 14, 2000 at 23:36 UTC
    If you can install modules, have you looked at Time::HiRes from CPAN? From the docs: gettimeofday () In array context it returns a 2 element array with the seconds and microseconds since the epoch.
Re: Sub-second Timing in Timestamps
by Anonymous Monk on Mar 15, 2000 at 02:06 UTC
    You can also use select to accomplish this by only using the 4th argument. For example, to sleep for only a half-second, you can use: select undef, undef, undef, 0.5;