
# We don't want the program to divide by zero if the input is empty
while (<>) {
  if (/^\d+$/) {
    $total += $_;
    $count += 1;
  } else {
    die "Input line $. walformed; noninteger.\n";
  }
}
if ($count) {
  $average = $total / $count;
  print "The average is $average.\n";
} else {
  print "Empty input; the average is undefined.\n";
}



