Browse - Programming Tips - How do I break up a string into lines in perl?
Q. How do I break up a string into lines in perl?
A. Here you go:
foreach $line (split(/\r\n|\n/, $contents))
This handles lines that end in CR-LF (line HTTP and Windows) or
LF (like Linux and iOS); the vast majority of situations.
It also preserves blank lines.
If you want to read a file into lines don't to the above, to do this:
while ($line = <FILE>)