in reply to adding newline to middle of a string cleanly
Also I highly recommend the module Text::Autoformat from CPAN that does a great job at text wrapping, justification, etc.$text =~ s/(.{30,40}(?<=\s\b))/$1\n/mg;
use Text::Autoformat qw(autoformat); $newtext = autoformat($text, { left=>1, right=>40, all=>1 });
|
|---|