Now, you might think that you can handle the situation like this:
but there is a catch. If $expire is for instance "100 yellow ribbons", Perl will say hey, you are using $expire as a number, so I'll make it a number for you. Since it starts with 100, I'll pretent its value is 100.. This may, or may not be what you want. (With warnings on, Perl will issue a warning in this case, a warning you also get if $expire equal "never"). It's a more serious issue if the range you compare against includes 0, as a string that doesn't start with something that looks like a number will be considered to be 0 if used in numeric context.if ($expire >= 90 && $expire <= 365 || $expire eq "never")
So, write your condition as:
You might want to modify the first clause if fractional values are to be accepted as well.if ($expire =~ /^\d+$/ && $expire >= 90 && $expire <= 135 || $expire e +q "never")
Abigail
In reply to Re: Is "N" ge 90 && le 365 or does "N" = <string>?
by Abigail-II
in thread Is "N" ge 90 && le 365 or does "N" = <string>?
by blink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |