in reply to Re^2: Why this code run faster?
in thread Why this code run faster?
Good eyes. When I change the test from if ($phrase2 =~ /^network$/g) {} to while ($phrase2 =~ /^network$/g) {}, the time went from 2.70s to 5.97s. This is in line with what I'd expect -- if 5E6 successful matches and 5E6 failed matches take 2.7s on my CPU, the while loop, consisting of 1E7 successes and 1E7 failures, should take about twice as long.