$threshold = "N" # see description above for($i=1;$i<=6;$i++) { my $pattern = "." x $i; while ($sequence_string =~ /($pattern)\1{$threshold,}/g) { .... } } #### while ($sequence_string =~ /(.)\1{$threshold,}|(.{2,3}?)\2{$threshold,}|(.{4,6}?)\3{$threshold,}/g) #### $i = 1; while ($i < $genome_length) { for ($j=1;$j<=6;$j++) { # run regexp looking for motifs of length $j # starting at position $i } $i = (end of previous match + 1) }