http://www.perlmonks.org?node_id=1009835


in reply to How to split a string based on length or word boundary

As long as your text doesn't contain any single words longer than your width:

$s = 'A really long string that I want to add to the awesome menu sys +tem';; print "| $_ |" for map substr( $_ . ' 'x16, 0, 16 ), $s =~ m[(.{1,16}) +\s+]g;; | A really long | | string that I | | want to add to | | the awesome menu |

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong