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 |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to split a string based on length or word boundary
by Athanasius (Archbishop) on Dec 21, 2012 at 02:54 UTC | |
by BrowserUk (Patriarch) on Dec 21, 2012 at 03:04 UTC | |
|
Re^2: How to split a string based on length or word boundary
by bcarroll (Pilgrim) on Dec 21, 2012 at 03:08 UTC | |
by BrowserUk (Patriarch) on Dec 21, 2012 at 03:27 UTC |