The stupid question is the question not asked | |
PerlMonks |
Splitting multiline string into words, the stuff between words, and newlinesby ibm1620 (Hermit) |
on Feb 24, 2022 at 00:15 UTC ( [id://11141603]=perlquestion: print w/replies, xml ) | Need Help?? |
ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
I want to split up an ASCII text document into words (as recognized by /b{wb}), strings of the non-word characters between words, and strings of newlines.
The following code almost works, but instead of treating the newlines as separate tokens, it leaves them appended to the preceding word
The output is:
I'm wondering what I'm doing wrong, and whether there's a better solution. (Would the split function be preferable?)
Back to
Seekers of Perl Wisdom
|
|