On Wed, Mar 01, 2006 at 09:30:26AM -0500, douglas.r.aker@verizon.com wrote:
I've been spending far too much time trying to accomplish a (seemingly) simple thing: use a Perl substitution operation to replace, a comma followed by a space followed by a single double-quote with a single double-quote.
Ok.
The obvious s/, "/"/g doesn't work, nor does escaping the double-quotes, as in s/, \"/\"/g
There's no reason to escape the double-quote, it has no special meaning in perl RE (same with the comma, the space, etc). The first version should work, assuming you're doing the substitution on $_. ie: $ perl -e '$_=q/Foo, "Bar", "Baz"/; s/, "/"/g; print "$_\n"' Foo"Bar""Baz" If it's not something simple like operating on the wrong variable or $_ not containing the data you expect it to, a possible more obscure issue that I've run into problems with is related to a bug in perl (typically 5.8.0) where the double-quote isn't properly dealt with sometimes. If this is the case, the solution I've used is to tell perl to not do Unicode (5.8.0 has a fairly buggy Unicode implementation) by putting "use bytes" at the top of the script. -- Randomly Generated Tagline: "It's not that we're afraid ... Far from it ... It's just that we have this thing about death ... it's not us." - Space Balls