in reply to string splitting with spaces and HTML
Have you tried HTML::Parser?
If you'd like quick and dirty hacks instead, try using Text::Wrap setting the columns to 40 and then splitting by newlines?