Oops. i went too fast. thats a preprocess command that i use with App::Cmd (highly recommended by the way) $args is an arrayref of filepaths read_file is provided by File::Slurp the regex is what you are looking for. The problem sucks since its a badly formatted file, but i normally just run that as a preprocessor and then use CSV_XS
On 6/8/07, Ben Tilly <[EMAIL PROTECTED]> wrote: > On 6/8/07, Gyepi SAM <[EMAIL PROTECTED]> wrote: > > On Fri, Jun 08, 2007 at 03:26:56PM -0400, Alex Brelsfoard wrote: > > > I have a CSV file where each line may NOT have the same number of fields. > > > One item per line. > > > > xSV is line oriented: as long as each line is well formed it should be > > parsed > > correctly. Making sense of the data may be more difficult though. > > Yup. > > > > But occasionally a field in an item will have one or more newlines in it. > > > How can I break this up correctly? > > > > Embedded newlines are OK as long as the field is quoted. However, not all > > tools will parse the field correctly. Last time I checked, Text::CSV and > > Text::CSV_XS do not. I suspect Text::xSV will be better behaved. There are > > other, non Perl, tools that should work fine as well. > > I had thought that Text::CSV did handle that case, but I just checked > and it does not. :-( > > Text::xSV does this correctly, though not speedily. Here is sample code: > > use strict; > use Text::xSV; > > my $csv = Text::xSV->new( > filename => "foo.csv", > row_size_warning => 0, # Stop warnings for variable size rows. > ); > while (my @row = $csv->get_row()) { > # Do something here. > } > > Cheers, > Ben > > _______________________________________________ > Boston-pm mailing list > Boston-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/boston-pm > _______________________________________________ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm