in reply to Insert breaklines into string

For wrapping lines to a maximum character count per line (for fixed pitch fonts), check out Text::Wrap.

For variable pitch fonts, the results would depend on the font used. I've built a custom solution once for Postscript fonts, using Font::AFM, but I don't know a similar, more generic (and better tested) module on CPAN. In short, what is needed, is to replace the simpleminded test for string length, with a test based upon stringwidth() of a substring, calculating the physical width of a text when printed.