in reply to Re: In search of a better way to trim string length
in thread In search of a better way to trim string
Though only the first line is 30, and the rest is 31 chars, i think it's more or less doing what you search for ?sub trimTo { my ($line, $length) = @_; $line=~s/([^ \s]{$length})([^ \s])/$1...\n$2/g; return $line; }
I just saw Jaspers solution, it's a bit different, i thought i post it anyway.
Addition:
Code isn't doing what was expected. Sorry Kiat :-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: In search of a better way to trim string length
by kiat (Vicar) on Jul 19, 2004 at 13:31 UTC | |
by Vennis (Pilgrim) on Jul 19, 2004 at 14:26 UTC |