http://qs321.pair.com?node_id=59291

dusk has asked for the wisdom of the Perl Monks concerning the following question:

Fellow devotees of the divine sect of Perlaism, I am having trouble, and I would appreciate any help. I am trying to get perl to append a newline after input of 80 words. Any suggestions will help :)

Replies are listed 'Best First'.
Re: forcing line-wraps?
by merlyn (Sage) on Feb 19, 2001 at 02:36 UTC
Re: forcing line-wraps?
by eg (Friar) on Feb 19, 2001 at 02:38 UTC

    Eighty words or eighty characters?

    If it's the latter, use Text::Wrap. If it's the former, um, split on /\s+/ and splice or concatentate newlines to the appropriate places. Something like (untested):

    for (my $i=79; $i<$#array; $i+=80) { $array[$i] .= "\n"; }