I've created a hash which looks as follows

keys values 5302 0 C 1 T 9046 0 G 1 A 11110 0 T 1 C 12640 0 T 1 C 18262 0 A 1 G 21994 0 A 1 G 25713 0 A 1 G 26638 0 T 1 G 28194 0 A 1 G 29841 0 G 1 A 30475 0 T 1 C 31503 0 A 1 C 32211 0 G 1 A 37138 0 G 1 A 41088 0 G 1 A 42626 0 A 1 G

using this I was hoping to replace values in another file which looks as so.

# ID 1005.csv 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1... 0 1 1 1 0 1 1 0 1 1 1 0 0 0 0 0 1 1 0... # ID 1009.csv 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1... 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1... etc...

each line of the hash represents the values of the file i want to alter in order i.e. the first line of the hash represents the first value in each line, the second line of the hash represents the second value in each line.

What I would like to achieve is at each position of each line replace the value (either 1 or 0) with the letter code that is represented by it's related line on the hash.

I've been bashing at this for days without any luck.


In reply to Using Hashes to replace values by b00mIR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.