]> granicus.if.org Git - curl/commitdiff
use Time::HiRes whenever available, independently of perl version
authorYang Tse <yangsita@gmail.com>
Tue, 22 Dec 2009 13:46:06 +0000 (13:46 +0000)
committerYang Tse <yangsita@gmail.com>
Tue, 22 Dec 2009 13:46:06 +0000 (13:46 +0000)
tests/ftpserver.pl
tests/runtests.pl

index cb60172e03bd9d38cf71445e0202e9fd388772d6..0f5aa55fb0ed3305e31755e7be5521a18c4e4222 100644 (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);
index f04a4c87050e5b9139fb055977c0b6a96d0ba605..536f604f8e090a2da771c73a8dc89bcd2b6c19dd 100755 (executable)
@@ -58,8 +58,9 @@
 
 BEGIN {
     @INC=(@INC, $ENV{'srcdir'}, ".");
-    # run time statistics needs perl 5.7 or newer
-    if($] >= 5.007003) {
+    # run time statistics needs Time::HiRes
+    eval {
+        no warnings "all";
         require Time::HiRes;
         import  Time::HiRes qw( time );
     }
@@ -3080,8 +3081,8 @@ while(@ARGV) {
         $keepoutfiles=1;
     }
     elsif($ARGV[0] eq "-r") {
-        # run time statistics needs perl 5.7 or newer
-        if($] >= 5.007003) {
+        # run time statistics needs Time::HiRes
+        if($Time::HiRes::VERSION) {
             keys(%timeprepini) = 1000;
             keys(%timesrvrini) = 1000;
             keys(%timesrvrend) = 1000;
@@ -3094,8 +3095,8 @@ while(@ARGV) {
         }
     }
     elsif($ARGV[0] eq "-rf") {
-        # run time statistics needs perl 5.7 or newer
-        if($] >= 5.007003) {
+        # run time statistics needs Time::HiRes
+        if($Time::HiRes::VERSION) {
             keys(%timeprepini) = 1000;
             keys(%timesrvrini) = 1000;
             keys(%timesrvrend) = 1000;