foreach my $i (1..40) { slow_match($i); } sub slow_match { my $count = shift || 20; my $str = ("yada " x $count) . "yad"; print "Trying to match $count iterations.."; die "Huh?" if $str =~ /^(\s*yada\s*)*$/; print "Done\n"; }