use strict; my $wr = qr/[-\w.,;:'"()]+/; # needs tuning sub trunc { my $max = shift or return ''; my $text = ' ' . shift or return ''; $text =~ s/^((?:\s+$wr){0,$max}).*$/$1/; substr($text, 0, 1) = ''; $text =~ s/\([^)]*$//; return $text; } DB<1> p trunc(5, " 'Twas (brillig), and the (slithy toves) did gyre and gimble in the wabe:" 'Twas (brillig), and the