Okay, I'm a totally newb and feel really frustrated. I need to write a simple script to do the following.
Open a file that contains information in the following format:
385#19126!NM_167210@[1103;1104] 2 386#19127!NM_167211@[1103;1104] 2 387#19128!NM_167212@[1103;1104] 2 438#1781!NM_135492@[1337] 1 442#1794!NM_001042886@[1349] 1
What I need is each entry between ! and @ (e.g., NM_167210) to be associated with its corresponding number value at the very end....so in a hash, the key would be NM_167210 and the value would be 2, another key would be NM_167211 and the value would be 2.
I then have another file with each of the NM entries having a corresponding entry called CG*****:
CG32694-RD NM_167211 CG32694-RC NM_167210 CG32694-RA NM_167209 CG32694-RB NM_167212 CG33557-RA NM_001014730
So what I want is to process the first file as stated above, and then keep the association but convert the NM field into the CG fields and yet keep the corresponding value for the NM field. For example:
key 167211 with value 2 needs to be converted to corresponding CG32694-RD.
How do I go about doing this? I have no idea how to even start. A hash of arrays? An array of hashes? Just a regular hash? An array instead?
My problem is that there are so many ways to approach this. Do I use m// or split or grep or all three of them? The advantage of a hash is that it would associate each NM with its value, whereas in an array, I would lose the association, no?
Heeeeeeeeeeeeeeelp! I h*** PERL!
In reply to ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions by mupud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |