use warnings; use strict; use Data::Dumper; my @totlines = map {chomp; [split /,/, $_]} ; #print Dumper \@totlines; my %hash = ( '_W9C2JJDCB' => [ '_W9C2JJDCB', '201200240', 'TEST: IGNORE', 'John Doe', 'Closed', 'HIP', 'email@email.com', 'email2@email.com', ], '_W9C2JJDCA' => [ '_W9C2JJDCA', '201200245', 'TEST: IGNORE', 'Jane Doe', 'Closed', 'HOP', 'email@imail.com', 'email2@imail.com', ], ); for my $line (@totlines) { my $key = $line->[0]; if ( defined $hash{$key} ){ push @{$hash{$key}}, @$line; } } print Dumper \%hash; __DATA__ _W9C2JJDCA,

This is the problem1.

,

This is res1

_W9C2JJDCA,

This is the problem2.

,

This is res2

_W9C2JJDCA,

This is the problem3.

,

This is res3

_W9C2JJDCB,

This is the problem1.

,

This is res1

_W9C2JJDCB,

This is the problem2.

,

This is res2

_W9C2JJDCB,

This is the problem3.

,

This is res3

_W9C2JJDCC,

This is the problem1.

,

This is res1

_W9C2JJDCC,

This is the problem2.

,

This is res2

_W9C2JJDCC,

This is the problem3.

,

This is res3