#!/usr/bin/perl use strict; use warnings; use IO::File; use Text::CSV_XS; use Data::Dumper; my $io = IO::File->new('myinputfile.txt','<') or die "Cannot open input file for reading: $!"; my $csv = Text::CSV_XS->new(); my %data; while (my $row = $csv->getline($io)) { # getline() reads a line from $io and parses it -- fast! # $row will contain an ARRAYref, one value for each element my $element_name = shift @$row; #first element is the name $data{$element_name} = $row; } print Dumper(\%data); # this will show you how the structure looks #### $VAR1 = { 'IL12::1::287' => [ '6', '-17', '-9', '-21', '-24', '-15', '-2', '11', '4', '4', '-15', '-26', '-16', '-9', '-18', '-25', '27', '17', '6' ] ... };