my @words = split / /, $string, 6; $words[-1] = '...' if @words==6; $string = join ' ', @words;