in reply to Read the csv file to a hash....
Not one of the answers addresses the problem with using <> for reading CSV lines that might have embedden newlines
use strict; use warnings; use Text::CSV_XS; my %hash; my $csv = Text::CSV_XS->new ({binary => 1, eol => "\n"}); open my $io, "<", "file.csv" or die "file.csv: $!"; my @fld = @{$csv->getline ($io)}; while (my $row = $csv->getline ($io)) { push @{$hash{$fld[$_]}}, $row->[$_] for 0 .. $#fld; } close $io;
|
|---|