in reply to [Homework Question] Subroutines & References

perltidy can help make this type of error more obvious by auto-indenting your code:
#!/usr/bin/perl use strict; use warnings; use List::Util qw(sum); my @list_of_numbers = ( 1 .. 50 ); my $i = (); my $a = (); sub mean { return sum(@_) / @_; } sub above_mean { $i == mean(@list_of_numbers); foreach (@list_of_numbers) { if ( $a > $i ) { print "$a is above mean, which is mean(@list_of_numbers)"; } print above_mean(@list_of_numbers);

Replies are listed 'Best First'.
Re^2: [Homework Question] Subroutines & References
by Hayest (Acolyte) on Feb 11, 2015 at 16:30 UTC
    Thanks for the suggestion, I could use that (big time). It still doesn't execute with the correct bracket location, however. Looking into it now... I'm a complete beginner with programming, and Perl. This community has been nothing but helpful to me. Thanks again!

      "Correct bracket location" doesn't enter into it.

      The hint is that your final print statement is deeply indented after tidying. It is indented to the same level as the if statement, because that's where it goes based on the brackets you wrote.

      You didn't want it to be at the same level as the if statement, and that's the clue that you need to add the close brackets.