in reply to problems parsing CSV
#!/usr/bin/perl -- use strict; use warnings; use Text::CSV; use Data::Dump::Streamer; Main(@ARGV); exit(0); sub Main { my $csv = Text::CSV->new; warn my $str = q!stuff,"more","foo (1994 "bar" only)",1234,1988,3. +0,""!; $csv->parse($str) and Dump( [ $csv->fields ] ); $csv->combine( qw' stuff more', 'foo (1994 "bar" only)', 1234, 1988, 3.0, "" ) and warn $csv->string; } __END__ stuff,"more","foo (1994 "bar" only)",1234,1988,3.0,"" at temp.pl line +14. stuff,more,"foo (1994 ""bar"" only)",1234,1988,3, at temp.pl line 16.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problems parsing CSV
by Anonymous Monk on Oct 09, 2010 at 14:22 UTC |