First, praise for using strict!
...and now couple more nits....
- By adding use warnings; perl would have told you some useful information.
- In total(), $number is not initialized. Sure you can ass-u-me that perl will set it to 0 but it will save you time and head ache later if you get in the habit of initializing all your variables (i.e., my $number = 0;)