Hello enderw2014, welcome to the monastery!
As choroba already said, the angle bracket operator returns everything that was read, including the final newline. Use chomp, or alternatively chop to remove it (the former, essentially being a smarter version of the latter, is usually the better choice). You can even chomp a variable at the same time as assigning to it:
chomp($number = <STDIN>);
A few other tips, since I imagine you're just getting started with Perl:
- Format your code to look nice. It may not matter for throwaway scripts you only run once to get a specific task done, but for anything you'll be coming back to later, it really pays off.
- use strict;. This will catch all sorts of issues that might come back to bite you later on. use warnings; may also be worth considering.
- Depending on the Perl version(s) you're targetting, enable modern features and make use of them, e.g. say.
- Also, just for the future: if your script produces errors or warnings you don't understand, use diagnostics; to get long-form explanations of what's wrong.
Have fun with Perl!