sub truncate_string($$) { my $string = shift; my $maxlength = shift; $string =~ s/^(.{,$maxlength})\b/$1.../s; return $string; }