R reinstein New member Jun 12, 2009 #1 here is an example text file; test goat 894 test cat 239 test rug 931 pet frog 352 how can i add up the values in the third column and display the total?
here is an example text file; test goat 894 test cat 239 test rug 931 pet frog 352 how can i add up the values in the third column and display the total?
M martinthurn New member Jun 12, 2009 #2 my $iTotal = 0; while (my $sLine = <>) { my ($junk1, $junk2, $i) = split /\s+/, $sLine; $iTotal += $i; } print $iTotal;
my $iTotal = 0; while (my $sLine = <>) { my ($junk1, $junk2, $i) = split /\s+/, $sLine; $iTotal += $i; } print $iTotal;