use strict; use warnings; use Time::HiRes qw(sleep gettimeofday tv_interval); my $test = 0; my $match = 0; while ( $test < 2000 ) { &sleepy($test); $test++; } print "A match occurred $match times"; sub sleepy { my $count = shift; my $time = gettimeofday; sleep(0.001); # Sleep here to ensure unique time my $hitime = gettimeofday; if ( $time == $hitime ) { $match++; } }