http://www.perlmonks.org?node_id=845416


in reply to Re: substr question
in thread substr question

That's the way I'd go too, but there's a little problem in your implementation:

$ perl -le'print "abc def" =~ m[(^.{0,100})\s]' abc
Fix:
m[(^.{0,100})(?!\S)]
m[(^.{0,100})(\s|$)]