This is a problem of logic, rather than Perl. The number 55 matches all three of your >= criteria, so you will of course get all 3 outputs. If you only want one output for each then consider reversing the order of your tests and using elsif for the other blocks. eg:
if ($number >= 50 ) { # ... } elsif ($number >= 20) { # ... } elsif ($number >= 10) { # ... }
This way you will get, at most, one line of output for any value of $number.
🦛
In reply to Re: subtracting numbers
by hippo
in thread subtracting numbers
by frank1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |