use Time::HiRes qw(gettimeofday); $start_time = gettimeofday(); $global_variable = "hello!"; for ($i = 0; $i < 10000000; $i++) { # replace this with "my" local $global_variable = "redefined. . "; } print gettimeofday - $start_time." seconds\n"; print "$global_variable\n";