Hi all, I am very new to perl, actually just start handling hash, here is a problem I'd really need some help:
Basically I have two hashes. Hash1 has keys and values, for each value, it contains elements separated by ",". By splitting each of the value, the elements would be keys that can be found in the Hash2. What I want is to obtain the values in the Hash2 to be assigned to each of the corresponding keys in Hash1.
For example
%Hash1=(
'key1', 'val1,val2',
'key2', 'val3')
for each value in Hash1, it can be split by ",", then val1 and val2 are individual keys can be found in Hash2, and val1 as key in Hash2 has values (val5,val6, val7), val2 as key in Hash2 has values (val8 and val9) and so on. e.g.
%Hash2=(
'val1','val5,val6,val7',
'val2','val8,val9',
'val3','val3')
I would like to obtain a result as:
%newhash=('key1','val5,val6,val7,val8,val9',
'key2','val3')
that is that the keys in Hash1 have all corresponding values in Hash2
my problem is that I cannot put values for val1 and val2 together for key1.
Any suggestions are greatly appreciated.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |