in reply to Counting characters in a string

Let's talk you through this. First of all, you want to substitute newlines for spaces:
s/\s/\n/g;
But you want the space to be preceded by at least 10 non-newlines:
s/(?<=[^\n]{10})\s/\n/g;
But this doesn't work, because the newlines we put in aren't found by the lookbehind, so we're going to have to consume and replace characters instead of using lookbehind:
s/([^\n]{10})\s/$1\n/g;
I'm still using [^\n] because I assume that if the string already has embedded newlines, you want the counter to reset.

Ok, bonus round: there is a way to do it with lookbehind, but it's ugly. We use \G to indicate where the last match left off. We want there to be at least 10 non-newlines between any new match and the old one. So:

s/(?<=(?:(?<!\G)[^\n]){10})\s/\n/g;
The lookbehind is "10 non-newlines, and be sure that none of them is immediately preceded by the previous match".

Update: Ok, re-reading the original question, we don't want to SUBSTITUTE for spaces, we want the newline to be inserted AFTER a space, and the space is (at least) the 10th character, meaning it's preceded by 9 chars. Thus:

s/([^\n]{9}\s)/$1\n/g;
(thanks to ambrus)

The PerlMonk tr/// Advocate