Perl: the Markov chain saw | |
PerlMonks |
Re: How can I split a line close to a certain length, but on a word boundary?by poznick (Initiate) |
on Apr 24, 2000 at 21:41 UTC ( [id://8730]=note: print w/replies, xml ) | Need Help?? |
I ended up using:
$rest = $messagebody; @text=(); while($rest ne '') { $rest =~ /(.{1,140}\W)/ms; push @text, $1; $rest = $'; }Text::Wrap doesn't provide the desired behavior, unless I were to do a tr/// to translate all the newlines into some strange character, do the wrap, and then tr the strange characters back to newlines. This way seemed a little cleaner.
In Section
Seekers of Perl Wisdom
|
|