in reply to Re: Escape Double Quotes
in thread Escape Double Quotes
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ sep_char => ',', keep_meta_info =>1 }); my $file = $ARGV[0] or die "Need to get CSV file on the command line\n +"; my $sum = 0; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$data>) { chomp $line; if ($csv->parse($line)) { my @fields = $csv->fields(); print $fields[1],"\n"; } else { warn "Line could not be parsed: $line\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Escape Double Quotes
by Anonymous Monk on Aug 07, 2014 at 14:50 UTC | |
by Tux (Canon) on Aug 07, 2014 at 15:59 UTC |