Hi Two files, if the first line and the first column are the same, print this line, the second line, the third line,the fourth line. What's wrong with me?

01.txt >SR1.2 >SR1.3 02.txt >SR1.1 HWI-ST ATGCTGCT TCGTCGAT CTGATCAGCTAC >SR1.2 HWI-ST0 TTTTGCTGCT TCGTTGGG CTTTATCAGCTAC >SR1.3 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC result >SR1.2 HWI-ST0 TTTTGCTGCT TCGTTGGG CTTTATCAGCTAC >SR1.3 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC #!/usr/bin/perl -w use strict; open(IN1,"01.txt") || die "Cannot open this file"; my @lines1 = <IN1>; open(IN2,"02.txt") || die "Cannot open this file"; my @lines2 = <IN2>; my $i=0; open(OUT,">out01") || die "Cannot open this file"; for my $item1(@lines1){ chomp $item1; my@tmp1=split(/\s+/, $item1); for my $item2(@lines2){ chomp $item2; my @tmp2=split(/\s+/, $item2); if ($tmp1[0] eq $tmp2[0]){ print OUT $lines2[$i],"\n",$lines2[$i+1],$line +s2[$i+2],$lines2[$i+3]; last; } $i++; } print OUT "\n"; } close(IN1); close(IN2); close(OUT);
Thanks in advance!

In reply to Two files, if the first line and the first column are the same, print this line, the second line, the third line,the fourth line. by yueli

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.