Listings from page 232
Chapter 6; page 232 (download)
use Time::HiRes 'time'; # So time() gives a high-resolution value. $StartTime = time(); "abababdedfg" =~ m/^(a|b|c|d|e|f|g)+$/; $EndTime = time(); printf("Alternation takes %.3f seconds.\n", $EndTime - $StartTime); $StartTime = time(); "abababdedfg" =~ m/^[a-g]+$/; $EndTime = time(); printf("Character class takes %.3f seconds.\n", $EndTime - $StartTime); |
Fetch additional Third-Edition listings and data: