joeorozco316 has asked for the wisdom of the Perl Monks concerning the following question:
#!C:\Perl\bin\perl use warnings; use strict; use Text::CSV_XS; my $file = "file.csv"; open FILE, $file or die "cannot open file\n"; my $first = <FILE>; my @columns = split(",", $first); my $csv = Text::CSV_XS->new ( { binary => 1 } ) or die "Cannot use CSV +: ".Text::CSV->error_diag (); $csv->column_names(@columns); my $lineNum = 1; while (my $line = <FILE>) { my $hr = $csv->getline_hr($line); my $sku = $hr->{ 'sku' }; print "$sku\n"; $lineNum++; } close FILE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: missing package or object reference
by Eliya (Vicar) on Dec 23, 2011 at 22:17 UTC | |
by NetWallah (Canon) on Dec 23, 2011 at 22:27 UTC | |
by joeorozco316 (Initiate) on Dec 27, 2011 at 16:13 UTC | |
|
Re: missing package or object reference
by Anonymous Monk on Dec 23, 2011 at 19:34 UTC | |
by joeorozco316 (Initiate) on Dec 23, 2011 at 19:54 UTC | |
by cavac (Prior) on Dec 23, 2011 at 22:04 UTC |