|Perl Monk, Perl Meditation|
split on comma-separated fields, where a field may have commas inside quotesby argv (Pilgrim)
|on Jun 10, 2009 at 00:08 UTC||Need Help??|
argv has asked for the wisdom of the Perl Monks concerning the following question:
I've been away from perl for a while, and coming back, I'm finding a situation that should be brain-dead simple, but I can't seem to hack it.
I need to do a split on a line with comma-separated fields, but some fields have commas in them, and are therefore surrounded by quotes. Here's a prototype line:
IBM,INTL BUSINESS MACHINES,"2,500",$108.14,$270350.00,$1625.00,0.60%,$126200.00, +$144150.00,+114.22%
The "2,500" is obviously the number of shares. How do get split to not divide it into separate fields?