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

Cap'n Steve has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to "nicely" truncate some text, which means not cutting any words in half. I haven't been able to find a module that does what I want, and this is what I've tried so far without success:
sub truncate_string($$) { my $string = shift; my $maxlength = shift; $string =~ s/^(.{,$maxlength})\b/$1.../s; return $string; }