Below is some test code that will be used in a larger program. What I am trying to do is process lines from a CSV file where some of the 'cells' have commas embedded in the (see sample code below). I might have used text::CSV but as far as I can tell that module also can not deal with embedded commas.
In the code below I have a regular expression who's intent is to look for " <1 or more characters> , <1 or more characters> " and replace the comma with |. (the white space is just for clarity). IAC, the regex works, that is, it matches, but it only replaces the final match. I have just re-read the camel book section on regexes and have tried many variations, but apparently I'm too close to it to see what must be a simple answer. BTW, if you guys think I'm posting too often, please say so. Barry Brevik ============================================ use strict; use warnings; my $csvLine = qq| "col , 1" , col___'2' , col-3, "col,4"|; print "before comma substitution: $csvLine\n\n"; $csvLine =~ s/(\x22.+),(.+\x22)/$1|$2/s; print "after comma substitution.: $csvLine\n\n"; _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs