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

How can I write a script to word wrap regular ascii text files. Basically I print things out and things get cut off on the right margin. What I'd like to do is run the text file through a script that word wraps so every line is n characters or less.

TIA

Replies are listed 'Best First'.
Re: Word wrap
by btrott (Parson) on Feb 22, 2000 at 22:43 UTC
    If the text of your file is loaded into the array @text:
    use Text::Wrap qw(wrap $columns); $columns = 70; print wrap('', '', @text);
Re: Word wrap
by japhy (Canon) on Feb 23, 2000 at 06:24 UTC
    Text::Wrap doesn't always work right. I wrote Text::Correct so you might want to use that. It's at search.cpan.org