in reply to output question
When the user enters a number, he finishes with an Enter. This Enter is part of the $number, you can remove it with chomp.