in reply to Why Does My Hash Become Undefined?

And for those who are not constrained by ill-advised corporate blindness, a solution in a few lines:
use Modern::Perl; use Text::CSV; use Data::Dumper; my $csv = Text::CSV->new () or die "Cannot use CSV: ".Text::CSV->error +_diag (); open my $fh, "<", 'test.csv'; $csv->column_names ($csv->getline ($fh)); my $arrayref = $csv->getline_hr_all ($fh); say Dumper(\$arrayref); # __DATA__ # First,Second,Third # 1,2,3 # One,Two,Three # Een,Twee,Drie

Output:

$VAR1 = \[ { 'Second' => '2', 'Third' => '3', 'First' => '1' }, { 'Second' => 'Two', 'Third' => 'Three', 'First' => 'One' }, { 'Second' => 'Twee', 'Third' => 'Drie', 'First' => 'Een' } ];

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James