my %hash; for ( map { [ split (/ - /, $_->[0]), [@{$_}[1..$#_]] ] } @nar ) { push @{$hash{$_->[0]}->{$_->[1]}}, $_->[2]; } print Dumper \%hash ;