kumarkeyan has asked for the wisdom of the Perl Monks concerning the following question:
What, "girl,boy", are_you, "good , one"
I want to read the data and print the data with double quotes. I can able to read the data but double quotes are not printed in the output.Please let me know how to print the data with double quotes.#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ sep_char => ',' }); my $file = $ARGV[0] or die "Need to get CSV file on the command line\n +"; 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"; } }
Expected Output: "girl,boy"
Actual Output: girl,boy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Escape Double Quotes
by toolic (Bishop) on Aug 07, 2014 at 13:09 UTC | |
by kumarkeyan (Initiate) on Aug 07, 2014 at 13:28 UTC | |
by Anonymous Monk on Aug 07, 2014 at 14:50 UTC | |
by Tux (Canon) on Aug 07, 2014 at 15:59 UTC | |
|
Re: Escape Double Quotes
by Anonymous Monk on Aug 07, 2014 at 15:30 UTC | |
|
Re: Escape Double Quotes
by Anonymous Monk on Aug 07, 2014 at 13:10 UTC |