#!/usr/bin/perl use strict; use warnings; use Benchmark ':hireswallclock'; # enable hires wallclock (microseconds) timing if possible my $iterations = 1; my $regexEngineCode = sub { my $x = "the quick brown fox\n"; $x x= 107374182; print length $x; ### 8 bytes less than 2^31. my $n=0; ++$n while $x =~ m[^.*$]mg; print $n; ### finds all the lines. ### Add another line that pushes the length a few bytes over 2^ $x .= "the straw that broke the camel's back\n"; print length $x; $n=0; ++$n while $x =~ m[^.*$]mg; print $n . "\n"; ### and it silently fails to find any of them. }; my $time = timeit($iterations, $regexEngineCode); print "It took ", timestr($time), "\n";