Welcome to the Monastery | |
PerlMonks |
Re: Split string using regex on \n or max line lengthby flowdy (Scribe) |
on Feb 10, 2017 at 08:08 UTC ( [id://1181638]=note: print w/replies, xml ) | Need Help?? |
Hi, I would do it in a string digestion loop:
Instead of substr, there are certainly other ways of splitting at fixed length, but this has just come to my mind first. Update: As $string is rewritten every iteration to another place in memory, haukex' solution performs probably better. Yet I would prefer a while loop instead, swallowing everything in an array first is seldom needed.
In Section
Seekers of Perl Wisdom
|
|