in reply to Parsing CSV into a hash

Here it is using Text::CSV_XS. Set the key_colnum to the number of the column you want to be key. Here it's set to 0 (the first column). This reads a "tab-delimited" file, set sep_char to something else if there's another delimiter.
#!/usr/bin/perl -w use strict; use Text::CSV_XS; use IO::File; my $csv = Text::CSV_XS->new({binary=>1,sep_char=>"\t"}); my $fh = IO::File->new( 'hdi.csv') or die $!; my $hash; my $key_colnum = 0; my $cols = $csv->getline($fh); while(my $vals = $csv->getline($fh)){ last unless @$vals; my %row; @row{@$cols} = @$vals; $hash->{ $row{ $cols->[$key_colnum] } } = \%row; } use Data::Dumper; print Dumper $hash;