in reply to Re: how to use the values of the first hash to be the keys for the second hash
in thread how to use the values of the first hash to be the keys for the second hash

People do love to change the question to suit their answer.
That was the author who changed the OP. Before the change, the structure of the hashes was not clear at all.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^2: how to use the values of the first hash to be the keys for the second hash

Replies are listed 'Best First'.
Re^3: how to use the values of the first hash to be the keys for the second hash
by lrl1997 (Novice) on Sep 10, 2012 at 05:09 UTC

    choroba was right that my original question was not clear. Thank you both for helping me on this, I really appreciate your help indeed. here is the code based on what I learned from here:

    my $hash1=shift; open (my $fh1, "<",$hash1) or die "$!"; my %h1=(); while (<$fh1>) { chomp; my ($k1,$v1)=split /\t/; $h1{$k1}=$v1; } my $hash2=shift; open (my $fh2, "<",$hash2) or die "$!"; my %h2=(); while (<$fh2>) { chomp; my ($k2,$v2)=split /\t/; $h2{$k2}=$v2; } my %combined_hash = map { $_ => join ',', map split(/,/, $h2{$_}), split /,/, $h1{$_} } keys %h1; while (my ($k, $v) = each %combined_hash) { print "$k\t$v\n"; }