in reply to querying a range of values
I believe your code does not print Yes due to operator precedence. My guess is thatuse Acme::Tools; if (between($frequency, 10, 15) {print "Yes"}
is the same as:if ($frequency == 10 .. 15) {print "Yes"}
in which case, the left side of the .. operator ($frequency == 10) is false, and in that case the whole expression is false. Refer to Range Operators.if ( ($frequency == 10) .. 15 ) {print "Yes"}
Update: add another example...
If you set it to 10, you will get a Yes:
but, you will get a warning if you use warnings; In any case, you should not try to use .. this way.my $frequency = 10; if ($frequency == 10 .. 15) {print "Yes"}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: querying a range of values
by jwkrahn (Abbot) on Jan 12, 2010 at 21:53 UTC | |
by toolic (Bishop) on Jan 14, 2010 at 01:47 UTC |