What's the best way to get Epoch milliseconds in Perl?

xsigndll picture xsigndll · Feb 27, 2011 · Viewed 12.2k times · Source

It's easy to get Epoch-Seconds (timestamp) in perl:

time

But what's with milliseconds? The most effective way seems to be time*1000, but that's not as accurate as I want it to be. Any good hints except for the long terms documented @perldoc?

Answer

oylenshpeegul picture oylenshpeegul · Feb 27, 2011

The Time::HiRes module has a drop-in replacement for time

$ perl -E 'say time'
1298827929
$ perl -MTime::HiRes=time -E 'say time'
1298827932.67446

You can read more in the perl FAQ

perldoc -q "How can I measure time under a second"