#!/usr/bin/perl -w

use strict;

use FileHandle;

my $fh = new FileHandle;
open($fh, "<namesgrades") or die "Couldn't open grades\n";

my $line;
my $count = 0;
my $sum = 0;

while($line = <$fh>) {
	chomp($line);
	my @cols = split(/ /, $line);
	$count++;
	$sum += $cols[0];

}

close($fh);

my $avg = $sum/$count;
print "The average is $avg\n";


