in reply to Truncate string

If you're a hardcore regexp junkie, you might prefer to ^[]$\\?. it:
sub cut { my ($str, $n) = @_; ($str =~ /^(?=.{$n})(.{0,@{[$n-1]}})\s(.*)$/s, $str, '')[0,1]; }
Greed helps here, of course. It always returns both halves of the string, though.