in reply to In search of a better way to trim string
Alternative with regex:
I think has the same behaviour as the others. Not tested fully. Not that I think it's any faster than any substr method, but it's an alternative.sub trimTo { my ($line, $length) = @_; $line =~ s/^(.{0,$length}\s|.{$length}).*/$1.../; return $line; }
In Section
Seekers of Perl Wisdom