Aja, that has allowed me to see the problem!
The (*SKIP) inside the repetition always matches, but once the end of the same-char sequence is reached the \2 fails, so it causes the repetition to backtrack, but it can't because of the (*SKIP), so all the repetition fails!
Moving the (*SKIP) after the \2 fixes the issue:
my $string = "ATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTTTTTT
+TTTTTTTTTTTATTGGGGACTTT";
my $len = 0;
my $best = "";
while ($string =~ /((.)(\2(*SKIP)){$len,})/g) {
$len = length $1;
$best = $1
}
print "best: $best\n"