How about this?
#!/usr/bin/perl use strict; my $file1 = <<END_FILE2; 334 138 34 39 - TAT_02 PAS_1 id_nu2 new2 545 154 83 11 + TAT_03 PAS_2 id_nu3 new3 765 131 21 12 - TAT_05 PAS_3 id_nu5 new5 END_FILE2 my %hash; open my $myfile, '<', \$file1 or die "cannot open file"; while (<$myfile>) { my (@lines) = split; $hash{$lines[5]} = [@lines]; } while (<DATA>) { my (@lines) = split; if ( defined( $hash{$lines[5]} ) && $hash{$lines[5]}->[5] eq $lines[5] ) { print join " ", @{ $hash{$lines[5]} } , "\n"; } else { print; } } __DATA__ 234 13 4 49 + TAT_01 id_nu1 explan1 236 123 3 67 + TAT_02 id_nu2 explan2 534 12 8 13 + TAT_03 id_nu3 explan3 764 124 9 33 + TAT_04 id_nu4 explan4 224 153 2 37 + TAT_05 id_nu5 explan5

In reply to Re: combining two files based on missing values by bichonfrise74
in thread combining two files based on missing values by sugar

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.