sub trimTo { my ($line, $length) = @_; $line =~ s/^(.{0,$length}\s|.{$length}).*/$1.../; return $line; }