From how I understand your question, this should help you get started. Note that there are many ways of doing this.
#!/usr/bin/perl use strict; use Data::Dumper; my %temp_record; my $file_1 =<<FILE_1; 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 FILE_1 open( my $fh, '<', \$file_1 ) or die( "Cannot open $file_1" ); while (<$fh>) { my ($key, $value) = /\!(\w+)\@\S.*\s+(\d)/; $temp_record{$key} = $value; } close( $fh ); my %record; while (<DATA>) { my ($key, $value) = /(\S+)\s+(\S+)/; for my $i (keys %temp_record) { $record{$key} = $temp_record{$i} if ( $i eq $value ); } } print Dumper \%record; __DATA__ CG32694-RD NM_167211 CG32694-RC NM_167210 CG32694-RA NM_167209 CG32694-RB NM_167212 CG33557-RA NM_001014730
The output is:
$VAR1 = { 'CG32694-RD' => '2', 'CG32694-RB' => '2', 'CG32694-RC' => '2' };

In reply to Re: ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions by bichonfrise74
in thread ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions by mupud

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.