in reply to Changing quoted strings spanning more than one line

This is a bit simpler and produces the correct result from your sample.

$_ = do{ local $/; <DATA> }; s[("[^\n"]+\n[^"]+")][ (my $x = $1) =~ s[\s+][ ]g; $x ]ge; print; "boom" hello "" bill "baz hello jock" "boom2" abc "baz2 hello2 jock2 "

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

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

    Unfortunately, it 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.

      Tad more complicated:

      $_ = do{ local $/; <DATA> }; s[("[^\n"]*?")|("[^\n"]+?\n[^"]+?")][ ##" $1 || do{ (my $x = $2) =~ s[\s+][ ]g; $x } ]ge; print; "boom" hello "" bill hello " " bill "baz hello jock" "boom2" abc "baz2 hello2 jock2 "

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.