http://qs1969.pair.com?node_id=11128801


in reply to Passing Variables

The problem is in your above_average sub. Perl flattens everything passed into one list. So, your @_ also contains the $average passed in. You should first remove $average using shift. Also, you should explicitly return your @final_list array. Change it to:
sub above_average { my $average_num = shift; my @final_list; foreach $_ (@_) { if ($_ > $average_num) { push @final_list, $_ } } return @final_list; }
For more details, see perlsub