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


in reply to Splitting multiline string into words, the stuff between words, and newlines

You can also use split for that in order to not require a regular expression for matching non words:
my @fragments = grep length, split /(\b{wb}.+?\b{wb}|\n+)/, $book;
So, you get words, sequences of new lines and then everything else.