Hi,
# ======================================================================
#
# Perl Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
#
# NAME: <Nandita.pl>
#
# AUTHOR: Aman Thind , Quark Inc
# DATE : 12/16/2002
#
# PURPOSE: <comment>
#
# ======================================================================
$file = 'C:\Documents and Settings\athind\Desktop\nandita.txt';
open FILE , $file;
while(<FILE>)
{
if(/Length *= *([0-9]*)/)
{
push @Ln , $1;
}
if(/Identities.*\/ *([0-9]*)/)
{
push @Dn , $1;
}
}
for($i=0 ; $i < scalar(@Ln) ; $i++)
{
if(@Ln[$i]!= 0)
{
$percentage = @Dn[$i]*100/@Ln[$i];
}
else
{
print "Length = 0 in Blah";
print $i+1;
print "!\n";
die;
}
push @Blah,$percentage;
if(@Blah[$i] > 50)
{
print "BLAH";
print $i+1;
print "\n"
}
}
#----------------------------------------------------------------
This should do the job.
Please adapt it to your liking.
-aman.
-----Original Message-----
From: Nandita Mullapudi [mailto:[EMAIL PROTECTED]]
Sent: Saturday, December 14, 2002 3:31 AM
To: [EMAIL PROTECTED]
Subject: picking numbers out of a file and operating on them
How does one tell perl to perform mathematical operations?
I have a file with a series of items like this:
>BLAH1
Length = 500
Identities = 20/100.
>BLAH2
Length = 400
Identities = 30/70
For each item called BLAH, I want to pick the denominator in Identites and
divide by Length and calculate percentage.
Eg. for BLAH1: 100/500 * 100 = 20%
and later , print all BLAHs for which the value is >50%.
I csn write reg exps to find the numbers i am interested in, but am not
sure how to go further..
thanks,
-nandita
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]