I'm sort of teaching myself perl and have a similar problem. I used the problem above but I'm not getting the same results. I want to find the average using a <STDIN> and subroutines.
You didn't describe the problem you are having. When I run your code, it seems to work fine for me. If I input the values 2 and 8, it correctly prints a result of 5.