my $thresh = 3; # as per Ikegami's note, pattern must repeat MORE THAN this many times while () { while (/((.{1,6})\2{$thresh,})/g) { printf "$2 (length=%d) repeats in $1\n", length $2; printf "Found at $-[0] to %d in $_", pos()-1; } } __DATA__ GATTATTATTATTATTATTGCATATATATAGCAAAAAATTTTTTGC ATATTATATTATATTATATTGC ATAGACATAGACATAGAC