$s = 'A really long string that I want to add to the awesome menu system';; 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 |