hi
open FILE1,"1.txt" or die "can't open file 1"; open FILE2,"2.txt" or die "can't open file 2"; open(w1,">3.txt"); open(w2,">4.txt"); while (my $line1 = <FILE1>) { chomp $line1; my @cond1 = split("\t" , $line1); print "$cond1[2]\n"; while (my $line2 = <FILE2>) { chomp $line2; my @cond2 = split("\t" , $line2); print "$cond2[2]\n"; if(abs($cond1[2]-$cond2[2])>=2) { print w1 "$line1\n"; print w2 "$line2\n"; } } } close FILE1; close FILE2; close w1; close w2;
i just want to open 2 files and find difference between cond12 and cond22 and if the difference is greater than or equal to some number say 2 print the lines again in 2 different files.
file 1 (1.txt) aqw dfr 34 poilo ggg 98 file 2 (2.txt) qww asd 28 poilo ggg 97
when i try this i am not able to get the output in proper way i mean my output should look like this
3.txt aqw dfr 34 4.txt qww asd 28
it would not print the other lines since the difference is less than 2

In reply to problem in looping by Anonymous Monk

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.