#some stuff like use strict, etc. Readonly my $udp_pinger => Net::Ping->new('udp',1); #other stuff, then beginning of loop my $t0 = [ gettimeofday() ]; `ping -q -w 1 -c 1 $host`; die if ($?); my $e0 = tv_interval($t0); print "Ping with backticks took $e0 seconds"; $t0 = [ gettimeofday() ]; $udp_pinger->ping($host) || die "udp ping failed for $host"; $e0 = tv_interval($t0); print "Ping with Net::Ping took $e0 seconds"; print ".."; #end of the loop