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


in reply to Re: (jeffa) Re: Wordwrap text
in thread Wordwrap text

This should also work:
#example 1 $content =~ s/(.{1,$width}) /$1<BR>/g; print $content;
or
#example 2 $content =~ s/(.{1,$width}) |([^ ]{$width})/$1$2<BR>/g; print $content;
The $width represents the largest number of characters each line should have.
The first example does not break single words longer than the variable $width specifies. The second will.