in reply to Reading in a text file with "multi line lines"

while (<>) { # read line while (s/\\$/ /) { # while the current line ends with \ # replace it by blank and append a new line. chomp; # thanks to ww $_.= <>; }

Update: the chomp should do it. Thanks to ww


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^2: Reading in a text file with "multi line lines"
by ww (Archbishop) on Nov 01, 2007 at 13:32 UTC
    Close, but the output doesn't join the lines, as OP asked. I think a big part of the problem is rooted in the thought-process behind your first comment, "current line ends with \," which, strictly speaking, is not the case. The lines in question actually end with a "\" and a newline.

    This helps (but does NOT solve; caveats below) if added after your second while :

    while (s/\n/ /s) { # remove the newlines my $out = $_; print $out; }

    Tested, more-or-less using GrandFather's "framework" (below). And just BTW or nitpicking, your (Skeeve's) comment "append a new line" would perhaps be clearer or less ambiguous if written as "append the next line from DATA.

    The problem (yep, this is the caveat) is that with multiple sets of data (which I infer from the OP's 'ignoring all the lines which are blank or contain just "space".') this still doesn't separate the sets, as does jmcnamara's, below, qv (and ++).