On 5/2/2011 4:23 PM, David Nicol wrote:
one way to handle commas in quotes strings in CSV files -- of course
if your data has angle brackets in it, or form feeds, you'll need a
different three characters.
while (<>){
while (/"/){
m/[<>\f]/ and die "ANGLE BRACKET OR FF IN INPUT! [$_]";
s/"/</; s/"/>/ or die "unpaired quotes in [$_]";
1 while s/<(.*?),(.*?)>/<$1\f$2>/;
s/[<>]//g;
};
my @line = split ',',$_;
s/\f/,/g for @line;
...
};
I usually use _Numeral (example: _1), as replacement values.
The underscore is rare in file bodies, and using a numeral with it gives
the ability to replace a set of entities.
Of course, order can be very important. :)
Teal
_______________________________________________
kc mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/kc