for $mh ( keys %mailhouse ) { foreach (@file) { ($g1,$g2,$g3,$g4,$g5) = split (/;/, $_,5); if ($mh eq $g4) { push @{ $mailhouse{$mh} }, $g1; } } }