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


in reply to Iterator to parse multiline string with \\n terminator

If your file is not terribly huge and/or you have enough memory, this is an alternative solution:
use Modern::Perl; my $file; { local $/ = ''; $file = <DATA>; } $file =~ s/\\\n/ /gs; my @lines = split /\n/, $file; say for @lines; __DATA__ First line Second line (part1)\ Second line (first continuation)\ Second line (second continuation) Third line (part1)\ Third line (first continuation)\ Third line (second continuation) Fourth line (part1)\ Fourth line (first continuation)\ Fourth line (second continuation)
Output:
First line Second line (part1) Second line (first continuation) Second line (seco +nd continuation) Third line (part1) Third line (first continuation) Third line (second +continuation) Fourth line (part1) Fourth line (first continuation) Fourth line (seco +nd continuation)

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics