in reply to What's wrong with my code? [from a beginner]
or even simpler as a one liner:my $sum; + open(FILE, "<$filename") || die "file $filename can't open : $!"; while(<FILE>) { $sum += ( split /\s+/ )[37]; } close FILE; print $sum;
shell> perl -naF\s+ -e "$sum+=$F[2]; END{print $sum}" file
|
|---|