rgbcof
asked on
perl, using parse_line to delimit by comma, but keep the double-quotes
I use parse_line to split a string based on comma (I don't have CSV library and do not want to install it), but I want to keep the double quote.
use Text::ParseWords;
my $mystring = "one, two, \"three\", four";
my $delim_char = ",";
my $delim_string = "\\s*$delim_char\\s*";
my @fields = &parse_line($delim_char,0, $mystring) ;
print join("\n",@fields),"\n";
use Text::ParseWords;
my $mystring = "one, two, \"three\", four";
my $delim_char = ",";
my $delim_string = "\\s*$delim_char\\s*";
my @fields = &parse_line($delim_char,0,
print join("\n",@fields),"\n";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
one
two
"three"
four
This is the output if you put the '1' in the code as explained above. Have a good one.
two
"three"
four
This is the output if you put the '1' in the code as explained above. Have a good one.
ASKER
Right on. Thanks
http://perldoc.perl.org/perlfaq4.html#How-can-I-split-a-[character]-delimited-stri
Good luck!