grep -v is an acceptable Unix command line method to exclude a line, but it does not qualify as a Perl solution ... at least not as a GOOD perl solution. Besides which, that would drop only one line from the file. Imagine a worst case in which you wind up excluding every line in a 1000 line file ... You would have to copy the file, sans one line, 1000 times.

What you want is to go through the file, line by line, using open(), while(), and close(), test each line, and if acceptable, copy it to the output file. That means only one copying of the file, whether you drop 0 lines or a million.

You say "the absolute value of column 2 minus column 2 ( I guess you mean column 3 ) is greater than or equal to 1". Except for the absolute value bit, I would test for $col2 > $col3. But it's significantly different whether you mean abs( $col2 ) > abs( $col3 ) or whether you mean abs( $col2 - $col3 ).

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


In reply to Re: Remove row if the absolute difference between two columns is greater than a threshold by TomDLux
in thread Remove row if the absolute difference between two columns is greater than a threshold by Renyulb28

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.