sub trimTo { my( $str, $n ) = @_; return $str if length $str < $n; substr( $str, 0, 1 + rindex( $str, ' ', $n-3 ) || $n-3 ) . '...'; }