in reply to Changing quoted strings spanning more than one line

No more testing than your sample, but the following could be considered a little cleaner:

use strict; use warnings; my @chunks = split '"', do{local $/; <DATA>}, -1; s/(?<=.)\s*\n\s*(?=.)/ /g for @chunks; print join '"', @chunks; __DATA__ "boom" hello "" bill "baz hello jock" "boom2" abc "baz2 hello2 jock2 "

Prints:

"boom" hello "" bill "baz hello jock" "boom2" abc "baz2 hello2 jock2 "

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Changing quoted strings spanning more than one line
by eyepopslikeamosquito (Archbishop) on Sep 19, 2007 at 05:47 UTC

    Like BrowserUk's solution below, this one similarly fails with the new test data (see root node update above). To clarify, if you run it with:

    hello "" bill hello " " bill
    it produces:
    hello "" bill hello " " bill
    when it should not alter the input data in this case.