title: Perl program to calculate the sum of the numbers that the user enters
body: <p>My script needs to get a series of numbers input by the user and find the average of them. I would like to use the line 'end-of-file' to show that the user is done inputting code. Any help would be appreciated. Below is what I have so far. I think I am really close, but I am missing something.</p>
  
  <p>Code:</p>
  
  <pre><code>#! /usr/bin/perl
  use 5.010;
  
  
  print "Enter the scores and type end-of-file when done";
  chomp(@scores = &lt;STDIN&gt;);
  foreach (@scores) {
      push_average(total(@scores));
  }
  
  
  
  
  sub total {
      my $sum;
      foreach (@_) {
          $sum += $_;
      }
      sum;
  }
  
  sub average {
      if (@_ == 0) {return}
      my $count = @_;
      my $sum = total(@_);
      $sum/$count;
  }
  
  sub push_average {
      my $average = average(@_);
      my @list;
      push @list, $average;
      return @list;
  }
  </code></pre>