my $string = 'a' x 50_000 . 'skjd'; my $regexp = qr-^((.){32000}\2{18000})skjd$-; print "yes\n" if $string =~ /$regexp/;