Hi,
I am trying to use a hash as a lookup to replace 'placeholders' in a file. I have some raw data that I have read into a hash which looks like this:
so the keys of the hash are the id's. I have another file which looks like this:
and so on. What i'd like to do is scan the file, using the hash to replace the id's with the actual values they are associated with, so that it looks like this:
hope that makes sense... i have tried a pattern matching approach to test each line to see if it contains a hash key, but can't seem to get it right. if anyone has more of a clue than me, that would be fantastic!
many thanks.
I am trying to use a hash as a lookup to replace 'placeholders' in a file. I have some raw data that I have read into a hash which looks like this:
Code:
id1 val1
id2 val2
id3 val3
so the keys of the hash are the id's. I have another file which looks like this:
Code:
enzyme: id1
interacts with: id2 id3
enzyme: id4
interacts with: id6 id7
and so on. What i'd like to do is scan the file, using the hash to replace the id's with the actual values they are associated with, so that it looks like this:
Code:
enzyme: val1
interacts with: val2 val3
enzyme: val4
interacts with: val6 val7
hope that makes sense... i have tried a pattern matching approach to test each line to see if it contains a hash key, but can't seem to get it right. if anyone has more of a clue than me, that would be fantastic!
many thanks.