Possible Duplicate:
concatenate hash values when key is same in perl
I want to store multiple values for a key in hash. For eg:
Input:
SMP00001 HMDB00641
SMP00001 HMDB00051
SMP00001 HMDB00052
SMP00003 HMDB00051
SMP00003 HMDB00517
SMP00004 HMDB00243
Output:
SMP00001: HMDB00641,HMDB00051,HMDB00052
SMP00003: HMDB00051,HMDB00517
SMP00004: HMDB00243
Here is the code I wrote:
push(@{$hash{$smp_id}},$HMDB_id);
When I print the content in hash the output is:
SMP00001 => ARRAY(0x161da40)
SMP00003 => ARRAY(0x11be28)
SMP00004 => ARRAY(0x1265c8)