open (BINFILE, $binaryfile) or die "Cannot open $binaryfile\n"; my @lines; while () { push (@lines, $_); } my %bin_file_data = (); for (@lines) { my @split = split (',', $_); my $sampname = $split[0]; my $binnumbers = $split[1]; my @bindata = split ('\t', $binnumbers); #I want $sampname as the key associated with the array @bindata $bin_file_data{$sampname} = @bindata; } print Dumper (\%bin_file_data); close BINFILE;