Oops!
Es muß natürlich so aussehen:
sub trim {
my $string = shift;
my @sentence = split(/\s+/,$string);
my $word_length_max = 40;
foreach $word (@sentence)
{
$word=~s/(.{$word_length_max})/$1-/sg;
}
$string = join(" ",@sentence);
return $string;
}
Norbert