File A

aa 22 310 1 300

ab 40 200 2 228

ac 51 230 10 241

df 23 240 22 242

ef 34 370 24 282

gh 24 125 22 210

df 76 290 11 232

wq 13 170 20 180

ss 89 288 12 270

Question is

I want to subtract 5th column with 4th column and That each one should be greater than 70 % of the top one of the third column (310) then print only thos e lines

Means say in the third column of top row is 310

then 70% of 310 is 70*370/100 is 217

Then subtract of 5th column with 4th column > 217 then only print which have greater than 217

aa 22 310 1 300

ab 40 200 2 228

ac 51 230 10 241

df 23 240 22 242

ef 34 370 24 282

df 76 290 11 232

ss 89 288 12 270

!/usr/bin/perl -w open (FILE,"$ARGV[0]") or die; my @temp =<FILE>; close FILE; foreach (@temp){ my @t= split("\t",$_); # $t[2],"\n"; if( $x =~ ($t[4]-$t[3]) > 70 * /100) { print "$x\n"; } }

Question si how to get top row of third column and then print these output


In reply to to print l columnwise and subtraction by vis1982

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.