#!/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;