in reply to Re: Pure variable confusion!
in thread Pure variable confusion!

I did the following the calculate the average:

my @average = $num_list_total / $size;

As far as my input goes I'm entering the numbers 1 3 6 7 8 (hitting enter after each) and the CTRL-D

Replies are listed 'Best First'.
Re^3: Pure variable confusion!
by GotToBTru (Prior) on Apr 22, 2015 at 00:45 UTC

    @average is an array; don't you mean $average? And you have the opposite problem at the end of your program. Your function above_average returns an array, but you have the value assigned to a scalar. I suggest you take the time to learn how to use the debugger. There are links to tutorials in the Tutorials section here. One of the great things about the debugger is you can check the contents of variables to make sure they are what you expect, and you can experiment with alternate code to find the solution.

    Dum Spiro Spero
Re^3: Pure variable confusion!
by Anonymous Monk on Apr 22, 2015 at 01:28 UTC
    Then what is this
    # my $average = average(@_); @average = average(@_);
    Where is sub average?

      That was my confusion. I calculated the average outside of the subroutine and I didn't know how to utilize it within it.

      Thanks for your help!