use Time::HiRes whenever available, independently of perl version

This commit is contained in:
Yang Tse
2009-12-22 13:46:06 +00:00
parent 7bede9180d
commit 271dc9c582
2 changed files with 12 additions and 8 deletions

View File

@@ -44,7 +44,9 @@ require "getpart.pm";
require "ftp.pm";
BEGIN {
if($] >= 5.007003) {
# sub second timestamping needs Time::HiRes
eval {
no warnings "all";
require Time::HiRes;
import Time::HiRes qw( gettimeofday );
}
@@ -141,7 +143,8 @@ sub getlogfilename {
#
sub logmsg {
my $now;
if($] >= 5.007003) {
# sub second timestamping needs Time::HiRes
if($Time::HiRes::VERSION) {
my ($seconds, $usec) = gettimeofday();
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($seconds);