while () { chomp; push @record, [split(/,/, $_, -1)]; } #### use strict; use Carp; # Time passes... sub read_csv { my $file = shift; local *CSV; open (CSV, $file) or confess("Cannot read '$file': $!"); my $header = ; chomp($header); my @fields = split /,/, $header; # You could do an error check for repeated field names... my @data; while () { chomp; my $row; @$row{@fields} = split(/,/, $_, -1); push @data, $row; } return @data; }