while () { chomp; my ($id, $accno) = split /\|/, $_; push @{$hashList{$guid}}, $accno; } #### while(){ chomp; s/\s+//g; if ($hashList{$_}) { for my $accno (@{$hashList{$_}}) { print FINAL_FILE "$_|$accno\n"; } } }