vis1982 has asked for the wisdom of the Perl Monks concerning the following question:
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 linesMeans 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: to print l columnwise and subtraction
by kennethk (Abbot) on Jul 20, 2010 at 14:53 UTC | |
|
Re: to print l columnwise and subtraction
by Utilitarian (Vicar) on Jul 20, 2010 at 14:56 UTC | |
|
Re: to print l columnwise and subtraction
by jethro (Monsignor) on Jul 20, 2010 at 15:11 UTC | |
|
Re: to print l columnwise and subtraction
by toolic (Bishop) on Jul 20, 2010 at 14:56 UTC | |
|
Re: to print l columnwise and subtraction
by suhailck (Friar) on Jul 20, 2010 at 14:52 UTC | |
by vis1982 (Acolyte) on Jul 21, 2010 at 09:44 UTC |