the function is:
sub parse_standard
{
my $filename = "myDocuments\\me\\info.csv";
#first, calculate the Avg and the number of rows
open(INPUT, $filename) or die "Cannot open $filename";
# Read the header line.
my $line = <INPUT>;
my $sum = 0 ;
my $counter = 0;
#Read the lines one by one.
while($line = <INPUT>)
{
chomp($line);
my ($Input,$Execution,$Output,$Total,$SelfTest,$Log_Location,$Log_Name) = split(',', $line);
$sum = $sum + $Input;
$counter = $counter +1;
}
$avg = $sum / $counter ;
#second , calculate the standard deviation
open(INPUT, $filename) or die "Cannot open $filename";
my $line = <INPUT>;
my $sum = 0 ;
#Read the lines one by one.
while($line = <INPUT>)
{
chomp($line);
my ($Input,$Execution,$Output,$Total,$SelfTest,$Log_Location,$Log_Name) = split(',', $line);
$diff = ($Input-$avg);
$square = $diff * $diff ;
$sum = $sum + $square;
}
$tosqrt = $sum / $counter;
$answer = sqrt($tosqrt);
print "standard deviation is $answer\n";
close(INPUT);
}
parse_standard();