in reply to string length problems

Maybe a bit less ugly?
I changed it from 5000 to 79 so that one can view the result.
$window=79; $i=-1; $str="X" x 723; substr($str,$i,0)="\n" while (($i+=$window+1) < length($str)); print $str;
This works by inserting "\n" at every $window+1 position.