#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %HoA; while (<>) { chomp; if ( $. <= 12 ) { if (index($_, ',') != -1) { my @fields = split(/,/, ); push @{ $HoA{$fields[0]} }, @fields; $. = 0 if $. == 12; # reset line number } else { warn "Line could not be parsed: $_\n"; } } } continue { close ARGV if eof; } print Dumper \%HoA; __END__ $ perl test.pl test.csv $VAR1 = { 'Anand' => [ 'Anand', '1', '2', '3', '4', 'xyz', 'Anand', '2', '3', '4', '5', 'wer', 'Anand', '3', '4', '4', '4', 'ert', 'Anand', '2', '2', '2', '2', 'tre' ], 'seetha' => [ 'seetha', '1', '2', '3', '4', 'rew' ] };