my $max = 230; (my $copy = $string) =~ s/(.{1,$max})\b.*/$1.../; print "$copy\n";