in reply to Chomping numbers?
davido has already explained how Perl converts strings to numbers which should answer your question. However, I'll point out an improvement to your input function:
sub input { print @_; my $r = <STDIN>; chomp $r; return $r; }
That way, the input function does your chomping for you, and you don't need to litter chomp calls throughout your code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Chomping numbers?
by 7cardcha (Novice) on Jul 18, 2013 at 14:23 UTC |