while(){ chomp; s/\s+//g; if ($hashList{$_}) { for my $accno (@{$hashList{$_}}) { print FINAL_FILE "$_|$accno\n"; } } }