my $col = ""; foreach my $key (keys %sampleValue){ my @col1 = split("\t",$sampleValue{$key}); $col = $col1[1].",".$col; } chop($col); print $col,"\n"; ## string of all the columns I am interested in