in reply to Text::Format Module q

Fun. As a one-liner:

perl -wlne"printf qq[\t'%s'\n], join qq['+\n\t'], m[(.{1,34}(?: |$)|.{34})] +g" junk.txt 'Here is one big long string which '+ 'needs to have some formatting done '+ 'to it before I can use it for '+ 'input in a separate program.' 'I would like it to be formatted '+ 'exactly as follows (except for the '+ 'exact line length)'

Or with a configurable line length

#! perl -slw use strict; for my $n ( 4 , 34, 70 ) { print "\n$n"; my $pos = tell DATA; while( <DATA> ) { chomp; printf "\t'%s'\n", join "'+\n\t'", m[(.{1,$n}(?: |$)|.{$n})]g; } seek DATA, $pos, 0; } __DATA__ Here is one big long string which needs to have some formatting done t +o it before I can use it for input in a separate program. I would like it to be formatted exactly as follows (except for the exa +ct line length)
P:\test>junk 4 'Here '+ 'is '+ 'one '+ 'big '+ 'long '+ 'stri'+ 'ng '+ 'whic'+ 'h '+ 'need'+ 's to '+ 'have '+ 'some '+ 'form'+ 'atti'+ 'ng '+ 'done '+ 'to '+ 'it '+ 'befo'+ 're I '+ 'can '+ 'use '+ 'it '+ 'for '+ 'inpu'+ 't in '+ 'a '+ 'sepa'+ 'rate '+ 'prog'+ 'ram.' 'I '+ 'woul'+ 'd '+ 'like '+ 'it '+ 'to '+ 'be '+ 'form'+ 'atte'+ 'd '+ 'exac'+ 'tly '+ 'as '+ 'foll'+ 'ows '+ '(exc'+ 'ept '+ 'for '+ 'the '+ 'exac'+ 't '+ 'line '+ 'leng'+ 'th)' 34 'Here is one big long string which '+ 'needs to have some formatting done '+ 'to it before I can use it for '+ 'input in a separate program.' 'I would like it to be formatted '+ 'exactly as follows (except for the '+ 'exact line length)' 70 'Here is one big long string which needs to have some formatti +ng done '+ 'to it before I can use it for input in a separate program.' 'I would like it to be formatted exactly as follows (except fo +r the '+ 'exact line length)'

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.