in reply to Changing quoted strings spanning more than one line

$/= '"'; while( <> ) { s/\s+/ /g if 0 == $. % 2 && /\n/; print; }

Update: Changed "if  0 == ( 1 & $. );" because the bit-op was a bit silly and to leave single-line strings uncollapsed.

- tye        

Replies are listed 'Best First'.
Re^2: Changing quoted strings spanning more than one line ($/)
by GrandFather (Saint) on Sep 19, 2007 at 04:01 UTC

    Collapses

    hello " " bill

    to

    hello " " bill

    which may or may not be important to OP's workmate.


    DWIM is Perl's answer to Gödel

      Yes. The requirement is to not change existing strings that do not span more than one line (I updated the root node with this extra line of test data to clarify the requirements).