in reply to Need help with Text::CSV
Please post the code that you are actually running. If I run your script, I get this output:
The documentation for Text::CSV states that this is how one defines the delimiter,Can't locate method setDelimiter at rb.pl line 8.
So, here is a slightly modified version of your script.my $csv = Text::CSV->new({ sep_char => '|' });
The output is:#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ sep_char => '|' }); # create a new object my $sample_input_string = '""|""|""|""|""|""|""|""|Submit|""|""|""|GSM +|GSM|'; if ($csv->parse($sample_input_string)) { my @field = $csv->fields; my $count = 0; for my $column (@field) { print ++$count, " => ", $column, "\n"; } print "\n"; } else { my $err = $csv->error_input; print "parse() failed on argument: ", $err, "\n"; }
I'm not sure why you expect your output to be:1 => 2 => 3 => 4 => 5 => 6 => 7 => 8 => 9 => Submit 10 => 11 => 12 => 13 => GSM 14 => GSM 15 =>
as that does not seem consistent with your script or your input data.Submit|GSM|GSM => 560
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with Text::CSV
by ravi45722 (Pilgrim) on Oct 28, 2015 at 05:52 UTC | |
by kcott (Archbishop) on Oct 28, 2015 at 06:28 UTC | |
by kevbot (Vicar) on Oct 28, 2015 at 06:30 UTC | |
by ravi45722 (Pilgrim) on Oct 28, 2015 at 08:49 UTC | |
by choroba (Cardinal) on Oct 29, 2015 at 16:58 UTC | |
by ravi45722 (Pilgrim) on Oct 30, 2015 at 04:06 UTC |