#!/usr/bin/perl use strict; use warnings; my $total = 0; my $num = 0; while (my $line = ) { my @tokens = split ' ', $line; # split removes line ending next unless @tokens == 3; # ignore blanks and header line $total += $tokens[-1]; # add last column $num++; } print "total = $total Average=",$total/$num,"\n"; # prints: total = 127297 Average=31824.25 __DATA__ CHECKPOINT 2017-08-01 20MICRONS 37744 2016-08-01 20MICRONS 25966 2016-04-20 20MICRONS 30807 2016-04-01 20MICRONS 32780