Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: time() smaller than seconds?

by turnstep (Parson)
on Apr 23, 2000 at 20:10 UTC ( [id://8655]=note: print w/replies, xml ) Need Help??


in reply to Is there a way to call time() with an increment smaller than seconds?

It's probably easier to just add something else to your primary key than to try and get sub-second responses. A good example is to use:
$mykey = "$^T$$";
which sets the key to a combination of the time in seconds and the process ID. This combination will be unique, as long as each time the script is run it generates a single key (e.g. a web script). If the script generates more than one key per second, add a counter:
$mykey = "$^T$$" . $x++;

If you do need sub-second times, you can look at the Time::HiRes module, although it may not work on your system, as it uses syscall and gettimeofday(2) in C. Probably easier overall to use the technique above.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://8655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found