Just keep in mind that Perl has a lot of DWIMery (Do What I Mean-ery) built-in. If you treat a string as a number, Perl will let you, and will attempt to return a reasonable value. If the string starts with a number, that number becomes the numeric value. If it doesn't start with a number, its numeric value will be zero. So "123abc" has a numeric value of 123. "abc123" has a numeric value of zero.
So Perl is happy to convert "123\n" to the numeric value 123. However, sanitizing your input at the earliest possible point is generally good practice. Getting into the habit of calling chomp on your textual input as soon as you receive it will help you to avoid forgetting about it later, and then wondering why $input ne "Hello!" # True, because we forgot to chomp.
Dave
In reply to Re^3: Chomping numbers?
by davido
in thread Chomping numbers?
by 7cardcha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |