how to create script for this formula?

Hello Unix gurus,
Can anyone tell me the most efficient way to create script for the formula?

Formula:

Ans = 1 - ((Buffer pool data physical reads + Buffer pool xda physical reads + Buffer pool index physical reads + Buffer pool temporary data physical reads + Buffer pool temporary xda physical reads + Buffer pool temporary index physical reads )
/ (Buffer pool data logical reads + Buffer pool xda logical reads + Buffer pool index logical reads + Buffer pool temporary data logical reads + Buffer pool temporary xda logical reads + Buffer pool temporary index logical reads )) * 100%

My input file is....

$ cat bphit.txt
Buffer pool data logical reads = 19622675514
Buffer pool data physical reads = 2032513088
Buffer pool temporary data logical reads = 2061535206
Buffer pool temporary data physical reads = 2156609
Asynchronous pool data page reads = 1206874663
Buffer pool data writes = 14270567
Asynchronous pool data page writes = 14226588
Buffer pool index logical reads = 11674823029
Buffer pool index physical reads = 137136399
Buffer pool temporary index logical reads = 0
Buffer pool temporary index physical reads = 0
Asynchronous pool index page reads = 24574557
Buffer pool index writes = 5594544
Asynchronous pool index page writes = 5566653
Buffer pool xda logical reads = 6
Buffer pool xda physical reads = 5
Buffer pool temporary xda logical reads = 0
Buffer pool temporary xda physical reads = 0
Buffer pool xda writes = 0
Asynchronous pool xda page reads = 0
Asynchronous pool xda page writes = 0

What will be the most efficient way to achieve this?

if you have Python, here's an alternative

d={}
for line in open("file"):
    line=line.strip().split(" = ")    
    d[line[0]]=int(line[1])

calculation = 1 - ((d["Buffer pool data physical reads"] + 
d["Buffer pool xda physical reads"] + 
d["Buffer pool index physical reads"] + 
d["Buffer pool temporary data physical reads"] + 
d["Buffer pool temporary xda physical reads"] + 
d["Buffer pool temporary index physical reads"] ) / (d["Buffer pool data logical reads"]+
 d["Buffer pool xda logical reads"] + d["Buffer pool index logical reads"] +
 d["Buffer pool temporary data logical reads"] + 
d["Buffer pool temporary xda logical reads"] + 
d["Buffer pool temporary index logical reads"] )) * 100
print calculation

similar, it can be done with awk. split on "=" using FS, then get them into associative arrays. then do the calculation.

Try this:

BEGIN {FS="="}
$0 ~ /Buffer pool data logical reads/{n1+=$2;next}
$0 ~ /Buffer pool xda physical reads/{n2+=$2;next}
$0 ~ /Buffer pool index physical reads/{n3+=$2;next}
$0 ~ /Buffer pool temporary data physical reads/{n4+=$2;next}
$0 ~ /Buffer pool temporary xda physical reads/{n5+=$2;next}
$0 ~ /Buffer pool temporary index physical reads/{n6+=$2;next}
$0 ~ /Buffer pool data logical reads/{d1+=$2;next}
$0 ~ /Buffer pool xda logical reads/{d2+=$2;next}
$0 ~ /Buffer pool index logical reads/{d3+=$2;next}
$0 ~ /Buffer pool temporary data logical reads/{d4+=$2;next}
$0 ~ /Buffer pool temporary xda logical reads/{d5+=$2;next}
40 ~ /Buffer pool temporary index logical reads/{d6+=$2;next}
END{
cal=1-((n1+n2+n3+n4+n5+n6)/(d1+d2+d3+d4+d5+d6))*100
print "Value is:",cal
}

cheers,
Devaraj Takhellambam

Thanks guys for your quick reply.

@ghostdog74 : Sorry I dont have Python.

@devtakh :
I really don't understand your code, why would anyone pull the lines from file and put in the script like you mentioned...I still think its not good idea.

Please understand my problem properly.
I have all these contents in a file...I want to have some script to which I can provide this file as input parameter...or anyother logic can do...apart from pulling lines out of the file and putting them in script...

You should be more specific on posting the requirement. Perhapes, define the pattern on how the formulae is to be arrived. It is only when you know the pattern, you can come to a logical conclusion to implement that in a program. So what is the pattern in this case?

Looking more deeply into the file, it appears to me that your numerator part of the formulae contains all the physical reads and the denomenator ones are all the logical reads. If that is the case, then

awk -F "=" '/physical reads/{p+=$2;next}/logical reads/{l+=$2}END{cal=1-(p/l)*100;print cal}' file

cheers,
Devaraj Takhellambam

Correct working script....
awk -F "=" '/physical reads/{p+=$2;next}/logical reads/{l+=$2}END{cal=(1-(p/l))*100;print cal}' file

Good that its working now. That was perhapes a typo in your original requirement.