in reply to Handling an embedded newline in an unquoted CSV field
You have to change the record separator to "\r\n"
use strict; use warnings; use 5.010; my $text = "field\n1,field2,field3\r\nfield4,field\n5,field6\n\r\n"; open my $fh, '<', \$text; local $/ = "\r\n"; while (<$fh>) { chomp; my ( $col1, $col2, $col3 ) = split ','; say "|$col1 $col2 $col3|"; }
Of course when you print it you'll see the new lines, if you don't want that either you can replace them.
|
|---|