in reply to Re: Need help with replace or substitute
in thread Need help with replace or substitute

You might want to look at Text::xSV or Text::CSV or Text::CSV_XS to break up the fields. Then you can just s/,/#/g on each field, and print back out the results delimited by commas.

Replies are listed 'Best First'.
Re^3: Need help with replace or substitute
by tachyon-II (Chaplain) on Apr 12, 2008 at 12:51 UTC

    Or with one line of regex code:

    $string =~ s/("[^"]*")/local $_=$1; s!,!#!g; $_ /ge;

    Yes it won't handle escaped double quotes but if you don't have that edge case it will never matter.

      the output with ur regex coming in this code snip as: "the, sample, string",345,43","A, next , string",12,-90 "the# sample# string",345,43"#"A, next , string",12,-90

        That's because your quoting is invalid.

      thanks this is much appreciated as we can't use any extra CPAN modules other than which are installed there due to some policy voilation.
Re^3: Need help with replace or substitute
by Anonymous Monk on Apr 11, 2008 at 23:45 UTC
    Hey Thanks, it worked for me.