in reply to Re^3: Tips on how to perform this regex query
in thread Tips on how to perform this regex query

Better
for my $o ( ($threshold-1)*$lenSmall .. $lenBig - $threshold*$lenSmall + ) {
But substr needs to handle negative offsets then.

Left as exercise!